views:

51

answers:

1

I got data measurements from image. I mean profile scan data. (image intensity values that are taken along one line) And what I want is to get data from another image's line and compare them together. I want to know if they are similar or not. For example I got:

int data1[N];
int data2[N];

And I want to compare them. If they are not similar, I wish to know the most longest part of that data, that are similar to each other. For example, it may happen so that data1 and data2 are not similar if we look at them at indexes from 0 to N - 1, but may be at indexes 100 ... N - 56 they are almost the same. By similarity I mean: if we represent data1 and data2 in the form of waves, then the similarity means that they behave almost the same, But may differ a little sometimes. I mean the form of the waves are almost similar.

+1  A: 

Clearly the exact implementation will be something more complicated than what I describe below, but perhaps it will offer a starting point:

Since you are talking about image intensity, it may be appropriate to normalize the the two sets of raw intensity data first. (That way, you should be able to recognize something where data1 is consistently two thirds of the data2 value.) I'd probably start by assigning a value of (for example) 100 to the most intense part of the source image and 0 to the least intense - adjusting all the other values to fit that scale.

Having normalized the data, the next step is probably as simple as iterating through the normalized arrays using some simple comparison (e.g. Abs(data1[n] - data2[n]) < SomeThreshold). Each time the comparison passes increment the "match length". If the match length was zero, you may also want to set a "start index" variable. When the comparison fails, update the "best match" information then reset the "length" counter to zero.

I would recommend making it easy to swap out the comparison function. I don't know for certain, but if you're trying to do some type of image matching I wouldn't be surprised if you have to use a more complex comparison mechanism (for example you may need the threshold value to "drift" if, for example, the basic image is the same but one of them has been post processed to make one side brighter than the original).

Richard J Foster
I did as you said, but the problem is that the threshold value differs from image to image. And may be even differs at different scan lines. It cannot be set to unique value.
erjik
Ah! I had misunderstood your original question and thought that you were *only* interested in a subset of scan lines (e.g. you were trying to compare the images faster by running the comparison only on every (for example) 10th row and/or column. If you are trying to compare the whole image, then you need to normalize both images.I'm not surprised the threshold can't be set to a simple value - as I mentioned in the last paragraph, depending on your needs you may (and apparently do) need something more complex.
Richard J Foster
The main problem with the simple threshold that I suggested is that it would really only work if all the images you are trying to compare have a similar dynamic range. If that is not the case, but you still wanted to use a simple threshold, you would probably need to initialize the threshold based on the dynamic range of one of the images (e.g. 3% of [max intensity - min intensity])By the way... the mechanism I described will not work well if image 2 is partially rotated, or a different size. If that is the case you will probably need some kind of feature-based comparison.
Richard J Foster