How to do GLPM to and image

조회 수: 4 (최근 30일)
pizzaa
pizzaa 2023년 6월 27일
댓글: pizzaa 2023년 6월 28일
Hi guys i have an image which is this
How to do GLPM and how to find peaks by thresholding? Ty

답변 (2개)

Gourab
Gourab 2023년 6월 28일
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
pizzaa
pizzaa 2023년 6월 28일
holyyy whank u guyss
pizzaa
pizzaa 2023년 6월 28일
let me try

댓글을 달려면 로그인하십시오.


Sharad
Sharad 2023년 6월 28일
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
pizzaa
pizzaa 2023년 6월 28일
let me try oke
pizzaa
pizzaa 2023년 6월 28일
@Sharad hello sir, how do i plot every peak gray peaks in taht image??

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by