Improve change detection from subtracting 2 images

I created 2 normalized images ('start' and 'last') by taking the average over 1 week.
I'd like to detect the change over time by subtracting the images from each other.
Visually, it is clear that there is some movement of rocks in the bottom left corner.
How can I improve the change detection of the images by focusing more on the movement of the rocks?
Ultimately, we would like to detect how much the rocks moved.
% Choose reference image
reference_image = imread(Timex_l_com(1).name);
reference_image = rgb2gray(im2double(reference_image));
for kl = 1:3(Timex_l_com)
Timex_end = imread(Timex_l_com(kl).name);
% apply histogram equalization to each channel (R, G, B) separately
for i = 1:3
Timex_end(:,:,i) = histeq(Timex_end(:,:,i));
end
% RGB to gray for image registration
Timex_end = rgb2gray(Timex_end);
% Perform image registration
[optimizer, metric] = imregconfig('multimodal'); % Define optimizer and metric
Timex_end_reg = imregister(Timex_end, reference_image, 'rigid', optimizer, metric);
% Convert back to RGB image
map = hsv(256);
Timex_end_reg = ind2rgb(Timex_end_reg, map);
Timex_end_reg = im2double(Timex_end_reg); % Normalize the image from 0 to 1
Timex_end_reg = Timex_end_reg./max(Timex_end_reg(:));
% Crop image
Timex_end_reg(:,[1:a1min],:)=[];
Timex_end_reg([1:a2min],:,:)=[];
Timex_end_reg(:,[uint64(a1max-a1min+1):end],:)=[];
Timex_end_reg([uint64(a2max-a2min+1):end],:,:)=[];
% Create average
if kl == 1
sumTimex_end = Timex_end_reg;
else
sumTimex_end = sumTimex_end + Timex_end_reg;
end
end
sumTimex_end = sumTimex_end / numel(Timex_l_com); % Calculate the average
movement = imabsdiff(sumTimex_end, sumTimex_start);
figure;
imshow(movement,[]);
colormap(autumn);
colorbar;

7 commentaires

Rik
Rik le 7 Fév 2023
The colors are wildly different between the two images, and the position of the camera is also not the exact same, making a pixel-by-pixel comparison with imabsdiff impossible without pre-processing.
You need to adjust the colors to match first, only then can you use this to automatically determine change. It is not obvious to me that this is actually possible.
Siegmund
Siegmund le 7 Fév 2023
Modifié(e) : Siegmund le 7 Fév 2023
Thanks Rik for your suggestions.
I added the loop how I created the 'last' image.
I know have added histogram equalization and register to have more uniform images.
Does this all makes sense to have a better end image to detect change?
Rik
Rik le 7 Fév 2023
Your newly attached images are a lot closer than the previous ones, but there I don't see any rocks moving around. I don't generally work with color images, so I don't know how to best proceed.
Perhaps you can try finding a mask describing which pixels are rocks and which are not, then you can use those to measure the movement.
Those were actually the pictures I used as input to create the average :-)
My result (now added) looks very dark so I don't know how to move forward.
Not sure how I can improve the creation of the average and difference in order to highlight regions of change.
I'll look into using mask
can you share input images? 'Timex_l_com' variable?
I added 4 input images now.
lightning conditions and colors are different in two images. try preprocessing to correct that then apply 'imabsdiff'.
https://in.mathworks.com/matlabcentral/answers/520327-color-normalization-algorithm-under-various-lighting-conditions

Connectez-vous pour commenter.

Réponses (1)

Mandar
Mandar le 8 Fév 2023

0 votes

The simple subtraction of two images might generate lot of false positives for several reason such as registration error, pixel movement etc. There many changes detection algorithms are available which process RGB images to identify the change between two images. You may find some pointers in the article ‘New Results in Change Detection Using Optical and Multispectral Images’ article to begin with.

2 commentaires

Thanks Mandar, I'll take a look at the paper.
I thought is was going to be a lot more straightforward when I started :-)
Would the above code (with some improvements) at least give a good approximation of regions of change or is it just faulty to do this?
If you want to test the efficacy of the code, try out publicly available databases which includes image pairs and ground truth. You can do a fair comparison between change map generated by the code and the ground truth. This exercise will help you to identify how efficient your approach is. However, not sure about the availability of image pairs and ground truth that has similarity to images in above code. Hence, you may need to make some changes to get the expected results.

Connectez-vous pour commenter.

Produits

Version

R2020b

Question posée :

le 7 Fév 2023

Commenté :

le 8 Fév 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by