Page 1 of 1

Image comparison - correcting brightness

Posted: 2013-10-22T05:48:22-07:00
by appu
Hi,

I use IM for verifying my application behavior(testing purpose) using the 'compare' function. But if the image has some brightness issue specific to rendering h/w, my tests are failing.

Image1 : Image
Image2 : Image

Normally for comparison purposes, I used NCC metric in gray scale mode. I tried NCC, AE and AE with fuzz on the mentioned images, but none of them showing a positive result. (at least 80% accuracy required)

Image size : 82x20

Code: Select all

	    colorspace	Approach	           Result
			
Image1	RGB	       NCC	                 0.187475
Image2	Gray         NCC	                 0.200187
			
Image1	RGB	       AE	                  1640
Image2	Gray	      AE	                  1636
			
Image1	RGB	       AE - fuzz 12%	       769
Image2	Gray	      AE - fuzz 12%	       709



I want to pass the comparison, if their is a yellow highlight and the text in the region is exactly what I've specified.
Can some one help me to resolve this issue ?

Re: Image comparison - correcting brightness

Posted: 2013-10-22T10:10:01-07:00
by fmw42
The two yellow colors are too different to pass with a small error. You must set your error tolerance higher for acceptance. The only way I can see that you will get a low metric result is using -metric AE and raising the -fuzz value rather large

compare -metric AE -fuzz 85% 2uetv90.png e05rib.jpg.png null:
0

Re: Image comparison - correcting brightness

Posted: 2013-10-22T12:43:02-07:00
by snibgo
You also have a scaling problem: the text is a slightly different size. You might pre-process each image to crop away the background, then rescale one to the same size as the other.

Re: Image comparison - correcting brightness

Posted: 2013-10-23T05:17:18-07:00
by appu
Thanks Fred, Snibgo for your suggestions. I'll try increasing the fuzz percentage as well as do the scaling properly

Re: Image comparison - correcting brightness

Posted: 2013-10-23T09:50:08-07:00
by fmw42
Apart from the scaling, you could convert all colors but black to white and then do the comparison.

convert image -fuzz XX% -fill white +opaque black newimage

Re: Image comparison - correcting brightness

Posted: 2013-10-24T11:30:18-07:00
by appu
Thanks Fred for the inputs. But it won't suffice my specific requirement, as I need to verify whether the yellow highlight is present in the region along with the text.

Re: Image comparison - correcting brightness

Posted: 2013-10-24T11:36:09-07:00
by snibgo
So you do two tests: one for the text, the other for the colour.

Re: Image comparison - correcting brightness

Posted: 2013-10-25T13:37:31-07:00
by appu
Two tests, I think will be expensive in terms of time. Any way, I'll have a try.

Can any one give inputs on how to find scaling factor of similar images, but scaled differently. Is there any standard methodology for identifying scaling measures b/w two images. If we found the scaling factor, how we can rescale it, using IM ?

Thanks in Advance.

Re: Image comparison - correcting brightness

Posted: 2013-10-25T13:40:04-07:00
by fmw42