i am trying to implement probality density function on an image but i can not understand how to calculate data, mu and sigma.here is my code is it right to take data as pixl value

k = imread('2.jpg');
img2=rgb2gray(k);
sigma =?;
mu=?
pd = makedist('Normal',mu,sigma);
data = img2(I,j)
y = pdf(pd,data);
figure,
plot(data,y,'LineWidth',2)

 Accepted Answer

mu = mean2(img2);
sigma = std2(img2);

4 Comments

Why should it be a scalar? You are expecting the output of pdf(pd,data) to be something you can plot(), which suggests you do not want a scalar output. pdf(pd,data) will return an array the same size as data, so pdf() does not need it to be a scalar.
actualy I am trying to calculate probability density function for img2

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!