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];
开发者_C百科
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.
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).
精彩评论