Thursday, 10 March 2016

How to calculate x and y of any object inside an image when stretched?



Suppose a image has


Height = 200px;
Width = 100px;

A point in that image which has


Y axis = 40px
X axis = 30px

Now if I resize that image:


New Height = 300px;

New Width = 150px;


Is there any formula to calculate new Y and X axis of that point?




Answer



Provided that the stretch is simply linear and consistent across the image, then the displacement of the point is proportional to the magnification factor.


For the X-Axis:



  • At $100px$ width, the point was at $30$


  • At $150px$ width, where would the point be? (Let's call this our unknown $x$).


$$x=\frac{150}{100} \times 30 = 45$$


Similarly, for the Y-Axis, the point will now be at $60$.


Hope this helps.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...