Link to home
Start Free TrialLog in
Avatar of Frutasamir
Frutasamir

asked on

Compare significant change between images

Hello, I want to compare two thermal images, being the first image the reference, and determine if the second image is significantly different from the first.

Therefore I want to apply a Kolmogorov–Smirnov test to compare these images;

"The two-sample KS test is one of the most useful and general nonparametric methods for comparing two samples, as it is sensitive to differences in both location and shape of the empirical cumulative distribution functions of the two samples."

http://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test#Test_with_estimated_parameters

http://www.lohninger.com/helpcsuite/ksquantile_statis.htm
(this site offers a KS test function)

I want to be able to use this method to compare drawn regions of the thermal images aswell (see unit attached)
Regi-es.pas
Avatar of EugeneZ
EugeneZ
Flag of United States of America image

Avatar of Frutasamir
Frutasamir

ASKER

hello, thanks for the post. But I don't use MATLAB,

The data I want to compare are temperatures of a whole image, or a region with another image, or region;

So I have a Stringgrid filled with data and I want to performa a KS-Test with another set of data.
The KS Test is meant to compare probability distribution functions.
Why do you think it is the right tool for images?
What do your thermal images look like?  What are the array dimensions?  Why are they different?  Are you looking at planets or people or machines?
There is a relevant paper here:
     http://link.springer.com/chapter/10.1007%2F978-3-540-24768-5_100#page-2

Note that they are not comparing the images per se,  but the distribution of pixel intensities.  They do go into some of the details of the calculation.

Is this the sort of processing you are trying to do?
KS-Test-for-Images.png
Looking at your code, you seem be dealing with color (RGB).  

For the sort of processing you are talking about, I think it is essential to treat the image as monochrome or grayscale.  You need to process false color back to intensity and then generate histograms for each image.

The KS test will let you compare different size images, or two sections of the same image.  
It is good for comparing large amorphous areas, but it isn't really suited for focusing in or selecting any sort of detail.
hello d-glitch,

I might as well don't even compare between images, with the code attached with the question, I have a stringgrid filled with the temperatures of the 600x600 image;

What I want is to performa a KS-test of that table that has a respective image, with another one;

See image attached,
image-table.jpg
I recognize the image: a three phase, high current AC connection with current transformers on each leg.  The actual temperature range in the image is only 10 deg C.

The thermal imaging camera is a wonderful tool.  But what is the engineering question you are trying to answer?  Whatever it is, I'm pretty sure the KS test will not help you find it.  I back up my opinion with a BSEE from MIT and 40 years of experience.

Where do your two images come from?  Is it two different connections, or the same connection at two different times?  Does the camera move between images?

If all that is changing is the temperature, the way to process the images would be generate the difference image, a simple subtraction, and maybe an RMS average.

If your situation is any more complicated, you probably need to think about image processing.
One more point:

>> If all that is changing is the temperature, the way to process the images would be  
      generate the difference image, a simple subtraction, and maybe an RMS average.

If all that's changing is the temperature (so that the images could be overlayed), then you could use the KS test on the entire image or on identical subsections.  But a straight difference would still be much simpler.
If you can wait, I will try this weekend to make simple example of how to implement KS for your needs.
Hello, the images being compared are always from the same equipment and taken at the same point.
Ok sinisav.
>>  But what is the engineering question you are trying to answer?

The TS test may tell you that the current image is different from the reference.  But it won't
tell what or where the change is.  It won't tell you if the change is hotter or colder.

If the reference image shows the center connection 50 degrees hotter than the others, and the current image shows the hot spot has moved to a different line, the TS test may not even pick up the difference.
In the code I can select which region I want to compare. So the KS test can be the whole image or just compare a portion;

But I see what you mean, the Ks-test would only say if it's different or considerably the same, what other way would you suggest I go for?
>> But what is the engineering question you are trying to answer?
 
Are you looking for a bad connection or an unbalanced load?
Are you trying to prevent a fire or evaluate available cooling?

Until I know what you want to do, I wouldn't know what to suggest.
I'm taking thermal images of electric boards, and as time passes I'll take some more images the same equipements, trying to reproduce the conditions of taking the earlier images;

Then passing those images to PC and save them on a MS Database;

What I want to develop is a way to compare these images that are in the database (I'll only compare between the same equipment)

So, at the moment I can save the images along with some information to the database, like name of the equipment and date that the image was taken;

And I can display the image temperature on a Stringgrid. Also select a region of an image and see the temperatures of that especific region;

So comparing electric boards, I'll have electric connections, increased temperature will mean:  poor electrical connections, short or open circuits, overloads, loads imbalance and improper equipments installation. In most cases, poor electrical connections are among the common problems in transmission and distribution lines of electrical power systems.
The essential data that should be stored with each image are the date and time, and the operating conditions, including the ambient temperature and the current in each phase.  Also need to note if the equipment is running steady state or if it has just turned on or off.

As far as processing the image data, the best thing to do might be to calculate temperature contour lines and gradients for the entire image.  Where the gradients are zero, you will have relative maxima and minima.  

A  maxima and the next lower contour line define a clear hot zone on the image.  Your example image would probably have 6 to 8 Hot Spots:  the three cable, the three connections, and maybe the middle current xmfr and that white spot in the back.

The sort of image processing you need doesn't require anything like Matlab.
so you're saying to implement something that detects automatically where the hotspots are, but in the images I'll always have the temperature scale, that will bugg out the system.

And other thing, by implementing something like that, how would you define if the image got worst (hotter) or better (colder)?

Thanks, Fruit.
You would be working with the 600x600 file of temperature data, not directly with the image.

After processing, you would wind up with a list of hot spots with the temperature and image coordinates of each.  Something like:
       (T=29.8,  x=500, y=300)
       (T=30.0,  x=350, y=350)
       (T=29.6,  x=200, y=400)
       (T=28.2,  x=600, y=500)
        ......  

Given two sets of hot spots, you can find out how close they are, in space and in temperature.
But in therms of user, how would the program tell if the difference is enough to worry;

Are you thinking of applying any algorithm or statistical method to insure that?
You will have to analyze enough data to know what normal behavior looks like.
And you have to include some abnormal/fault condition data.  Even if you have to simulate it or generate faults intentionally.

At that point you should be able to define alarm conditions.

For example, you might find that under normal operation at 400A, you see eight hot spots with a temperature 45 deg C over ambient.

A possible set of alarm criteria could be
     less than 6 hot spots   OR  more than 10 hot spots  OR
     peak temp less than  40 deg C over ambient           OR
     peak temp more than 50 deg C over ambient
If the image processing is too complicated, you could do something simpler.

Find the max temperature in the array/image.
Count the number of pixels that are greater than (T_max - 2).  
If you plot these pixels black and everything else white, you will have a map of the hot spots.

If you calculate the fraction of hot/black pixels in the image, you might have a very useful parameter.  It would certainly be more useful (and easier to calculate) than the KS test.
>>  If you plot these pixels black and everything else white, you will have a map of
      the hot spots.

This map would be a perfect candidate for a simple blob detection algorithm.
     http://www.labbookpages.co.uk/software/imgProc/blobDetection.html
I'll wait for the KS-test,

But could you prepare examples of both alarm sets and black and white  map of hotspots? I liked those Ideas.
if you want me to support with more thermal images, please say so.
A few files and images would certainly be helpful:  the base case, a second "normal" image, and at least one "abnormal" image.
Sending you some thermal images; some are with normal behavior and the respective anomaly image. Some are just with position or scale change.

These images are in a different color spectre, but I think that's ok.

I also attached a recent papper in thermography, I hope it's enough.
Electric-board-anomaly.jpg
Electric-board-normal.jpg
grounding-bus-board-anomaly--fro.jpg
Grounding-bus-board-normal--fron.jpg
Grounding-bus-board-normal--side.jpg
grounding-bus-board-anomaly--sid.jpg
image-scale1.jpg
image-scale2.jpg
image-position1.jpg
Image-position2.jpg
Paper-thermography.pdf
Did the images I sent you work?

have you come to any conclusion?
SOLUTION
Avatar of d-glitch
d-glitch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial