Home > Software engineering >  Resize image and it's bounding box in x,y,w,h format
Resize image and it's bounding box in x,y,w,h format

Time:06-20

I have an image of width 1980 and height 1080 having x =759 ,y = 786, w = 369,h = 100. I want to convert this image into width = 640 and height = 480. How can I convert bounding box according to new image format?

CodePudding user response:

As you know the actual (W,H) and new image format (newW,newH) then

newX = (newW/W) * x

and do the same for other value...

Edit:

newY = (newH/H) * y

And the same for other value.

  • Related