필터 지우기
필터 지우기

Normal distribution

조회 수: 5 (최근 30일)
Jaanu
Jaanu 2011년 11월 2일
Hi, i need to calculate the normal distribution value for an image. for that,i used the following coding,
I=imread('image1.jpg');
K = double(I(:));
mu=mean(K);
sigma=std2(K);
P=normpdf(K, mu, sigma);
Z = norminv(P,mu,sigma);
when i use some images it is giving the values. but sometimes it is giving like 'NaN'.I don't know how to solve this problem. Please help me.

답변 (2개)

Christopher Kanan
Christopher Kanan 2011년 11월 2일
Instead of casting the image as a zero, you might consider using im2double. Otherwise your image values may be very large causing a floating point problem.
You should check to see if any non-finite values ( see isfinite) are present in mu, sigma, P, or just Z. Since you are treating K as a vector, you could use std instead of std2 as well.
I=im2double(imread('image1.jpg'));
K = I(:);
mu=mean(K);
sigma=std(K);
P=normpdf(K, mu, sigma);
Z = norminv(P,mu,sigma);
  댓글 수: 1
Jaanu
Jaanu 2012년 6월 10일
still i am getting NaN value. could you please suggest any other solution.

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


Walter Roberson
Walter Roberson 2011년 11월 2일
Check to see whether the images that work (or do not work) are all RGB images and the others grayscale ?
Also, check to see if sigma is perhaps coming out 0.
Note: You might as well use std(K) instead of std2(K) as std2(K) is just std(K(:)) but K is already a column vector in your code.
  댓글 수: 1
Jaanu
Jaanu 2012년 6월 10일
sometimes, why is mean value giving zero? even if i apply your hint too?

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

Community Treasure Hunt

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

Start Hunting!

Translated by