i have following code compares 2 images , outputs how many pixels different. i'm trying figure out how make output x , y coordinates of pixels. have idea?
public int count2; public boolean flag; private void button1_click(object sender, eventargs e) { string img1_ref, img2_ref; //this image 10x10 bitmap img1 = properties.resources.black; //this image screenshot bitmap img2 = properties.resources.bigimg; (int = 0; < img1.width; i++) { (int j = 0; j < img1.height; j++) { img1_ref = img1.getpixel(i, j).tostring(); img2_ref = img2.getpixel(i, j).tostring(); if (img1_ref != img2_ref) { count2++; flag = false; break; } } } if (flag == false) messagebox.show(count2 + " wrong pixels found"); }
these images, , small black square should found in middleish of big image:
how having list stores wrong pixels?
list<point> wrongpixels = new list<point>(); [...] if (img1_ref != img2_ref){ wrongpixels.add(new point(i,j)); [...] } [...] (int i=0, max=wrongpixels.count;i<max;i++){ messagebox.show("wrong pixel at: " + wrongpixels[i].tostring()); }
Comments
Post a Comment