c++ - Coordinates of a pixel between two images -
i looking solution compute pixel coordinate 2 images.
question: if take following code, how compute pixel coordinate changed "qvector difference" ? possible have (x,y) coordinate , find on currentimage pixel represents ?
char *previousimage; char *currentimage; qvector difference<long>; for(int = 0 ; < currentimagesize; i++) { //check if pixels same (we can rgb values, example) if(previousimagepixel != currentimagepixel) { difference.push_back(currentimage - previousimage); } currentimage++; }
edit: more information topic:
- the image in rgb format
- the width, height , bpp of both images known
- i have pointer bytes representing image
the main objective here know new value of pixel changed between 2 images , know pixel (its coordinates)
there not enough information answer, try give idea.
you have declared char *previousimage;
, implies me have pointer bytes representing image. need more interpret image.
- you need know pixel format. mention rgb, -- time being, let's assume image uses 3 bytes each pixel , order rgb
- you need know width of image.
- given above 2, can calculate "row stride", number of bytes row takes up. "bytes per pixel" * "image width", typically padded out divisible 4. 3 bpp , width of 15, 45 bytes + 3 bytes of padding make row stride 48.
- given that, if have index image data, first integer-divide against row stride row (y coordinate).
- the x coordinate (index mod row stride) integer-divided bytes per pixel.
Comments
Post a Comment