how can use kurtosis in 2D gray scale image segmentation?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Image Analyst
le 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 commentaires
Image Analyst
le 6 Fév 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.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!