Improve change detection from subtracting 2 images
Afficher commentaires plus anciens
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
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.
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.
Siegmund
le 7 Fév 2023
prasanth s
le 8 Fév 2023
can you share input images? 'Timex_l_com' variable?
Siegmund
le 8 Fév 2023
prasanth s
le 8 Fév 2023
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
Réponses (1)
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
Siegmund
le 8 Fév 2023
Mandar
le 8 Fév 2023
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.
Catégories
En savoir plus sur Ground Truth Labeling dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
