Borrar filtros
Borrar filtros

Pixel intensity vs distance (probability distribution function)

5 visualizaciones (últimos 30 días)
Andreea DUMITRESCU el 27 de Abr. de 2022
Respondida: Sudarsanan A K el 2 de Nov. de 2023
Dear All,
I have to compute the PDF for pixel separations of similar intensity values for an image.
For intensity values I tried imhist, but the plot is number of pixels/intensity. I need a distribution function for distance/pixels with similar intensity.
How to do it?

Respuestas (1)

Sudarsanan A K
Sudarsanan A K el 2 de Nov. de 2023
Hello Andreea,
It is my understanding that you are asking how to compute the Probability Density Function (PDF) for pixel separations of similar intensity values in an image using MATLAB. Specifically, you are interested in obtaining a distribution function for the distance in pixels between pixels with similar intensity values in the image.
I assume that you can use a threshold to quantify the similarity of intensity values of pixels in the image.
Here is an example which performs this:
% Step 1: Read the image
image = imread('cameraman.jpg');
% Step 2: Convert the image to grayscale
grayImage = rgb2gray(image);
% Step 3: Calculate the intensity values
[counts, grayLevels] = imhist(grayImage);
% Step 4: Compute separations between similar intensity values
threshold = 500; % Adjust this threshold as needed
similarIntensities = find(counts > threshold);
separations = diff(similarIntensities);
% Step 5: Plot the histogram
subplot(1, 2, 1);
bar(grayLevels, counts);
title('Image Histogram');
% Step 6: Plot the PDF of separations
subplot(1, 2, 2);
histogram(separations, 'Normalization', 'pdf');
xlabel('Pixel Separation');
title('PDF of Pixel Separations');
% Adjust figure width
set(gcf, 'Position', [100, 100, 1200, 400]);
Note that the "threshold" is used to determine what intensity values are considered similar. By setting a threshold value, we can filter out low-frequency intensity values that may not be of interest and focus on those intensity values that are more prevalent or significant in the image.
Yo can additionally refer the following MathWorks documentations for better understanding of the "imhist()", "find()" and "diff()" functions that I have used in the example:
I hope this helps!


Más información sobre Image Filtering and Enhancement en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by