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.

  1. you need know pixel format. mention rgb, -- time being, let's assume image uses 3 bytes each pixel , order rgb
  2. you need know width of image.
  3. 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.
  4. given that, if have index image data, first integer-divide against row stride row (y coordinate).
  5. the x coordinate (index mod row stride) integer-divided bytes per pixel.

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -