Similar features in images

10 visualizzazioni (ultimi 30 giorni)
Edin Michael
Edin Michael il 3 Mar 2025
Risposto: Rahul il 6 Mar 2025
I have a time based spray images and would like to find out the distance travelled by a wave between two images. The waves mostly retain their shape but undergo slight changes. I am attaching relevent images along with this. The waves are marked with boxes.

Risposte (1)

Rahul
Rahul il 6 Mar 2025
Hi Edin,
To determine the distance traveled by the wave between two consecutive images, you can use MATLAB’s image processing and feature-matching techniques. First, the images are converted to grayscale to ensure consistent intensity analysis, which simplifies further processing.
gray1 = rgb2gray(img1);
gray2 = rgb2gray(img2);
Edge detection, typically using the Canny method, can then be applied to highlight the wave boundaries effectively.
edges1 = edge(gray1, 'Canny');
edges2 = edge(gray2, 'Canny');
To estimate displacement, techniques such as normalized cross-correlation can be used, which help in identifying the pixel shift between the two images by finding the peak correlation point.
c = normxcorr2(edges1, edges2);
[~, imax] = max(abs(c(:)));
[yPeak, xPeak] = ind2sub(size(c), imax);
Alternatively, feature-based methods like SIFT or SURF can be used to track distinctive wave features that remain consistent across frames. For more dynamic motion estimation, MATLAB’s optical flow functions, such as 'opticalFlowFarneback,' can be useful in analyzing pixel-wise velocity across frames. Once the displacement in pixels is determined, it is converted into a real-world distance using a known spatial scaling factor (e.g., pixels per millimeter).
real_distance = displacement * scale;
The accuracy of this approach can be further enhanced using image registration techniques 'imregcorr' to align images before computing displacement. Depending on the level of precision required, different methods can be combined or refined. For more details, you can refer to the following documentation links which can be leveraged to optimize the analysis:
Hope this helped!

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by