How to determine the period of a pattern contained in a grayscale image?

4 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
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
Glypton
Glypton il 4 Giu 2022
Modificato: Glypton il 4 Giu 2022
Thank you for your response!
I am new to image processing. There is no image per se. Just a big matrix with values between 0-255 or 150-255 since there are no black pixels contained in the matrix. The actual dimension of the matrix is 86x6*10^5. I extracted the first 6*10^4 columns to show you what I want to achieve. This means that the above pattern is repeated 10 times with some noises. Now I try to calculate the period of that pattern. So, there is no image but a big matrix. Sorry for being unclear and thank you again for your response!
Image Analyst
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.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by