Azzera filtri
Azzera filtri

How to do GLPM to and image

3 visualizzazioni (ultimi 30 giorni)
pizzaa
pizzaa il 27 Giu 2023
Commentato: pizzaa il 28 Giu 2023
Hi guys i have an image which is this
How to do GLPM and how to find peaks by thresholding? Ty

Risposte (2)

Gourab
Gourab il 28 Giu 2023
Hi pizzaa,
From your question I get that you want toperform the Gray Level Profile Method (GLPM) and find peaks by thresholding in an image.
Follow these steps to perform GLPM and find peaks:
  1. First Convert the image to grayscale if it is not already in grayscale. This can be done using the “rgb2gray” function in MATLAB.
  2. Calculate the gray level profile of the image. The gray level profile represents the variation of gray levels along a certain direction in the image. You can choose a specific direction (horizontal, vertical, diagonal) based on your requirements. To calculate the gray level profile, you can use the “improfile” function in MATLAB.
Refer to the below code snippet.
% Convert image to grayscale
imageArray = imread('GLPM.png');
grayImage = rgb2gray(imageArray);
% Calculate gray level profile along the horizontal direction
%Pass the direction and the number of points to the "improfile" function
profile = improfile(grayImage, [50, 500], [50, 300], 10);
smoothedProfile = smoothdata(profile);
% MinPeakHeight is the threshold value
[peaks, peakLocations] = findpeaks(smoothedProfile, 'MinPeakHeight', 5);
figure;
plot(profile);
hold on;
plot(peakLocations, peaks, 'ro', 'MarkerSize', 8);
xlabel('Position');
ylabel('Gray Level');
title('Gray Level Profile with Detected Peaks');
You can refer to the below documentation for more information.
  2 Commenti
pizzaa
pizzaa il 28 Giu 2023
holyyy whank u guyss
pizzaa
pizzaa il 28 Giu 2023
let me try

Accedi per commentare.


Sharad
Sharad il 28 Giu 2023
Hi,
As per my understanding, you are interested in doing gray-level co-occurrence matrix (GLCM) analysis and also find out the peaks by thresholding.
Here are some steps that you can follow:
  • Install the Image Processing Toolbox from the MATLAB add on explorer.
  • Load the image and convert it into grayscale ( if not already).
img = imread('image.jpg');
grayImage = rgb2gray(img);
  • Use the graycomatrix function provided by MATLAB to compute the GLCM of the grayscale image that you created.
glcm = graycomatrix(grayImage, 'Offset', [0 1], 'NumLevels', 256);
  • Compute and understand the required gclm properties.
% Compute GLCM properties
properties = {'Contrast', 'Correlation', 'Energy', 'Homogeneity'};
glcmProps = graycoprops(glcm, properties);
% Access specific GLCM property and analyze
contrast = glcmProps.Contrast;
correlation = glcmProps.Correlation;
energy = glcmProps.Energy;
homogeneity = glcmProps.Homogeneity;
  • Determine the peaks using the imregionalmax function after choosing an appropriate threshold value.
threshold = 0.5; % Adjust the threshold as needed
peaks = imregionalmax(glcm) & (glcm > threshold);
Here are some documentations that you might want to follow:
  2 Commenti
pizzaa
pizzaa il 28 Giu 2023
let me try oke
pizzaa
pizzaa il 28 Giu 2023
@Sharad hello sir, how do i plot every peak gray peaks in taht image??

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by