Search code examples
imagematlabcomparison

MATLAB image distinction/comparison


I have 1024 images, each of which has the size 150(y) x 270(x) which is stored as 3D array with the size of 150 x 270 x 1024

First 160 images are very similar to each other but not entirely identical;

however, after 160th image, pictures start to change drastically.

So, here is what I want to achieve:

I want to find the index of the image from which the images start to drastically change

I have tried to compare correlation between image #1 and other 1023 images by:

for ii = 1:1023
    R(ii) = corr2(input(:,:,1),input(:,:,ii+1)); % input = 3D array (150 x 270 x 1024)
end

and see if there is any change in correlation coefficient at around 160th image, but wasn't successful.

What method can I use to detect changes in these images and to find the index at which my images start to change dramatically?

EDIT

following are some of the images I have (index in the title)

I guess the change is not as dramatic as I first described and when you look at image 160 and 161, the change is subtle but as it goes on, you can clearly see that the image definitely changes at the bottom part

These images are results of ultrasonic testing and wave propagation from PZT sensor starts at the bottom part of the image

enter image description here enter image description here enter image description here enter image description here enter image description here


Solution

  • Probably, this is not a full answer to your problem, but I hope I can give you some ideas to further work on. But before, I have to mention this: Image processing is two-dimensional signal processing! ;-)

    After reading your question the 34th time (or so), I finally saw, that you're comparing "image" #1 with all others. Instead, you should compare neighbouring "images". I have put together the following script incorporating your approach of using corr2:

    load('fullSet.mat');
    
    %% Normalize values to [0, 1] with respect to whole volume. 
    %% Just for nicer image showing.
    %minV = min(fullSet(:));
    %fullSet = fullSet - minV;
    %maxV = max(fullSet(:));
    %fullSet = fullSet / maxV;
    
    % Determine number of "images".
    n = size(fullSet, 3);
    
    % "Step size".
    s = 1;
    
    % Initialize R.
    R = zeros(n-s, 1);
    
    % Compute correlation coefficients.
    for ii = 1:n-s
        R(ii) = corr2(fullSet(:, :, ii), fullSet(:, :, ii + s));
    end
    
    % Show output.
    figure(1);
    
    subplot(3, 1, 1);
    plot(1:n-s, R);
    title('R');
    xlim([0 n-s]);
    
    subplot(3, 1, 2);
    plot(1:n-s-1, diff(R, 1));
    title('1st derivative of R');
    xlim([0 n-s-1]);
    
    subplot(3, 1, 3);
    plot(1:n-s-2, diff(R, 2));
    title('2nd derivative of R');
    xlim([0 n-s-2]);
    

    The "step size" defines which "image" should be compared to the current one, i.e. s = 1 is used to compare the current "image" with the next "image", s = 2 is used to compare the current "image" with the second-next "image", and so on.

    The results for s = 1:

    s = 1

    The results for s = 5:

    s = 5

    The results for s = 10:

    s = 10

    As you can see, there is a distinct change around [160, 200]. I also computed the 1st and 2nd derivatives, because here you can also see changes later in your "volume" - if this is of interest for you.

    Please let me know, if you need further explanations on my script or if you need further help in general.