how can use kurtosis in 2D gray scale image segmentation?

6 views (last 30 days)
I wrote this code to find skewness and kurtosis for a 2D gray scale image, I wondered if is it right like this? and how can I use the kurtosis output image to segment the input image into objects?
I = imread('cameraman.tif');
figure;imshow(I), title('input image');
I = double(I);
[n m] = size(I);
skewness = zeros(size(I));
kurtosis = zeros(size(I));
M = zeros(8,1);
V = zeros(8,1);
MO3 = zeros(8,1);
MO4 = zeros(8,1);
r = 1;
for i = 1:n
for j = 1:m
for ii=-1:1
iwin=ii+i;
if iwin<1;
iwin=1;
end
if iwin>n;
iwin=n;
end
for jj=-1:1
jwin=jj+j;
if jwin<1
jwin=1;
end
if jwin>m
jwin=m;
end
if r<= 8
M(r,1) = I(iwin,jwin);
else
r = 1;
end
end
end
%calculate the mean value
m1 = ((sum(M))+I(i,j))/9;
%calculate the variance
for r = 1:8
V(r,1) = (M(r,1) - m1)^2;
MO3(r,1) = (M(r,1) - m1)^3;
MO4(r,1) = (M(r,1) - m1)^4;
end
x = (I(i,j)-m1)^2;
deviation = ((sum(V)+x)/9)^0.5;
x3 = (I(i,j)-m1)^3;
x4 = (I(i,j)-m1)^4;
%calculate the 3rd moment (skewness) high order statistic
moment3 = (sum(MO3)+x3)/9;
skewness(i,j) = (moment3/(deviation)^3);
%calculate the 4rd moment (skewness) high order statistic
moment4 = (sum(MO4)+x4)/9;
kurtosis(i,j) = (moment4/(deviation)^4);
end
end
figure, imagesc(skewness), title('skewness image');
figure, imagesc(kurtosis), title('kurtosis image');
thanks in advance

Accepted Answer

Image Analyst
Image Analyst on 27 Jan 2015
I'm attaching my demo on computing image moments like skew and kurtosis. I'm having trouble conceptualizing the kind of image where its kurtosis would be the best thing to use for image segmentation. Why are you considering that instead of other more traditional measurements? Can you attach your image and tell us what you'd like to measure?
I'm not sure what your triple for loop is doing because you didn't add any comments. What is it doing? What is M?
  14 Comments
Rasha
Rasha on 6 Feb 2015
Edited: Rasha on 6 Feb 2015
I apologies for late reply Image Analyst, yes it is in matlab toolbox, as in this link
<http://www.mathworks.com/help/stats/kurtosis.html?searchHighlight=kurtosis>
and it's like you said a function of each column in image, so I tried to make the program above to find a kurtosis for each pixel but the resulted image refuse the function imhist to show the histogram of it. where is the wrong you think?
I need to understand the kurtosis very well to use it in watershed segmentation as reprocessing or in the processing, I don't want to use edge detection ordinary methods, I know they better for edges, I want to know what benefit of taking kurtosis for whole image? and for each pixel?
thanks
Image Analyst
Image Analyst on 6 Feb 2015
You can use blockproc() to do it. See attached examples. Replace one of the functions in the demo (like the median filter) with kurtosis. I still think there is a lack of theory behind it in general, but whatever...it's your project.

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!