简体   繁体   中英

c# Image Coordinates Processing

If we have 2 same images. One is small and one is big. Now we have xy value on small image

then how we will map it on the same position on big image. Can anyone tell me with formula?

I'd imagine you'd just scale it:

int bigX = smallX * (bigWidth / smallWidth);
int bigY = smallY * (bigHeight / smallHeight);

Note that you may wish to use floating point arithmetic to avoid integer arithmetic issues:

int bigX = (int) (smallX * ((double) bigWidth / smallWidth));
int bigY = (int) (smallY * ((double) bigHeight / smallHeight));

Simply use proportions.

Point bigpoint = new Point((int)(smallpoint.X * bigwidth/smallwidth), 
             (int)(smallpoint.Y * bigheight/smallheight));

// Assuming that Point smallpoint is the pixel of small image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM