How to determine the period of a pattern contained in a grayscale image?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Glypton
il 4 Giu 2022
Commentato: Image Analyst
il 4 Giu 2022
Hello,
I want to determine the period of a specific pattern in a grayscale image. The matrix representing the image is a 86x60000 matrix containing values between 0-255 (grayscale). I read about different approaches using functions like findpeaks, ischange and crosscorrelation to determine the period but I am not quite sure how I could use them in order to solve my problem. I am new to matlab and therefore I am not familiar with all functionalities matlab provides. Do you have any ideas how to tackle this problem?
Here is a picture that illustrates what I want to calculate.
0 Commenti
Risposta accettata
Image Analyst
il 4 Giu 2022
Not too hard. Just threshold then scan to find the top edge. Then invert and call findpeaks. Here's a start
grayImage = imread(fileName);
if ndims(grayImage) > 1
grayImage = rb2gray(grayImage);
end
mask = grayImage > someThresholdValue;
[rows, columns] = size(grayImage);
topRows = rows * ones(1, columns);
for col = 1 : columns
tr = find(mask(:, col), 1, 'first');
if ~isempty(tr)
topRows(col) = tr;
end
end
% Invert
topRows = rows - topRows;
% Find peaks
[peakValues, columnsOfPeaks] = findpeaks(topRows, 'MinPeakDistance', columns/10);
peakValues = rows - peakValues;
% Plot on image.
hold on;
x = 1 : columns;
plot(x(columnsOfPeaks), peakValues, 'rv', 'MarkerSize', 15, 'LineWidth', 2);
Attach your actual image if you can't figure it out.
2 Commenti
Image Analyst
il 4 Giu 2022
It doesn't matter what you call it: image or matrix. Essentially they're the same. If you need any more help, ask. And attach the matrix in a .mat file with the paperclip icon.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!