Image comparison - correcting brightness

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
appu
Posts: 29
Joined: 2013-09-20T10:10:02-07:00
Authentication code: 6789

Image comparison - correcting brightness

Post 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 ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image comparison - correcting brightness

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image comparison - correcting brightness

Post 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.
snibgo's IM pages: im.snibgo.com
appu
Posts: 29
Joined: 2013-09-20T10:10:02-07:00
Authentication code: 6789

Re: Image comparison - correcting brightness

Post by appu »

Thanks Fred, Snibgo for your suggestions. I'll try increasing the fuzz percentage as well as do the scaling properly
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image comparison - correcting brightness

Post 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
appu
Posts: 29
Joined: 2013-09-20T10:10:02-07:00
Authentication code: 6789

Re: Image comparison - correcting brightness

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image comparison - correcting brightness

Post by snibgo »

So you do two tests: one for the text, the other for the colour.
snibgo's IM pages: im.snibgo.com
appu
Posts: 29
Joined: 2013-09-20T10:10:02-07:00
Authentication code: 6789

Re: Image comparison - correcting brightness

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image comparison - correcting brightness

Post by fmw42 »

Post Reply