torcellite / imageComparator

Comparing images with OpenCV on Android
106 stars 78 forks source link

Same photo with different brightness #2

Open nibalk opened 10 years ago

nibalk commented 10 years ago

Thanks for the great effort. Need some help to solve the below mentioned issue. I have noticed that if we use the same photo with different brightness it consider that two photos as "Not duplicates". I have tried below example, but didn't work. Imgproc.cvtColor(img1, img1, Imgproc.COLOR_RGB2HSV); Imgproc.cvtColor(img2, img2, Imgproc.COLOR_RGB2HSV);

Could you please help me with this ? Thanks!

torcellite commented 10 years ago

You could convert both images to grayscale and then check for similarities.

nibalk commented 10 years ago

Thanks for the quick reply. Does it mean that we have to do something like this ? Imgproc.cvtColor(img1, img1, Imgproc.COLOR_RGBA2GRAY); Imgproc.cvtColor(img2, img2, Imgproc.COLOR_RGBA2GRAY); Or simply use the Android way of grayscale the image ? Thanks!

torcellite commented 10 years ago

The code you've written above should do it. On Feb 17, 2014 12:21 PM, "nibalk" notifications@github.com wrote:

Thanks for the quick reply. Does it mean that we have to do something like this ? Imgproc.cvtColor(img1, img1, Imgproc.COLOR_RGBA2GRAY); Imgproc.cvtColor(img2, img2, Imgproc.COLOR_RGBA2GRAY); Or simply use the Android way of grayscale the image ? Thanks!

Reply to this email directly or view it on GitHubhttps://github.com/torcellite/imageComparator/issues/2#issuecomment-35232441 .

nibalk commented 10 years ago

oopsss! Even if I tried it still it can't identify it as duplicate images :) I will have a look again.

Do you have any idea how to change the code to show only the mismatching areas of the two images. Currently it's showing the matching areas using green color lines. I want to do it the other way round. I have already tried passing the mismatches to below method. But didn't work.

I might be doing some crazy thing. :) I have no idea of OpenCV API. Any good resource to refer it.

Thanks!

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Features2d.drawMatches(img1, keypoints, img2, dupKeypoints, missmatches, img3, GREEN, RED, drawnMatches, Features2d.NOT_DRAW_SINGLE_POINTS);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < totalMatchCount; i++) { if (matchesList.get(i).distance <= min_dist) { matches_final.add(matchesList.get(i)); } else { missmatches_temp.add(matchesList.get(i)); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////