フィルターのクリア

finding skewness, kurtosis

7 ビュー (過去 30 日間)
rob
rob 2012 年 4 月 8 日
コメント済み: Image Analyst 2017 年 11 月 23 日
This code does not give any result for skewness, kurtosis, and rms roughness. What is wrong with this simple snippet? Matlab does not give any error. M is a number matrix here.
function [avg, rms, sk, ku] = parameters(M)
rms=0;
k=0;
M=M(:);
% Average roughness
avg=mean(M);
for i = 1:numel(M)
% RMS roughness
k=sqrt((M(i)-mean(M))^2/numel(M));
rms=rms+k;
end
% skewness
sk=skewness(M);
% kurtosis
ku=kurtosis(M);
sprintf('%d', '%d', '%d', '%d', avg, rms, sk, ku);
  2 件のコメント
arun anoop m
arun anoop m 2017 年 11 月 23 日
X = randn([1 2]) y = skewness(X); ku=kurtosis(X); avg=mean(X); y ku avg
Image Analyst
Image Analyst 2017 年 11 月 23 日
Please, since this is an "Answer", NOT a comment asking for additional information, put it down in the Answers section with the rest of the answers, so you can get credit for it.

サインインしてコメントする。

回答 (2 件)

Wayne King
Wayne King 2012 年 4 月 8 日
Why do you have this line in your function:
sprintf('%d', '%d', '%d', '%d', avg, rms, sk, ku);
First of all those values will not be integers, so don't use %d
Your function outputs the arguments avg, rms, sk, and ku so remove that line from your function, run your function from the command line, and then you will see that you have variables: avg,rms,sk, and ku.
If you want, you can just remove the semicolon after sprintf in your function and it will print the values to the command window, but I don't think you need to do that (if you do that, do not use %d)
You can do something like:
sprintf('mean value is %2.3f\n',avg)
sprintf('RMS value is %2.3f\n',rms)
What values you use with %f depend on your data range.
But again, you output those values to the workspace.
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 4 月 8 日
Or change the sprintf() to fprintf()
rob
rob 2012 年 4 月 8 日
Thank you Wayne, the reason i used that command was because i was not getting any output to the workspace. I'm using R9a 7.9.0. Thank you for your suggestion Wayne. Walter, thank you too. It worked. Now i'm trying to optimize the code and will revert back. Have a happy Easter.

サインインしてコメントする。


Image Analyst
Image Analyst 2012 年 4 月 8 日
Rod, I don't have whatever toolbox those functions are in.
I gave code for computing the third and fourth central moments (skew and kurtosis) of image intensitiess in http://www.mathworks.com/matlabcentral/answers/15307-image-operations-skewness-and-kurtosis>
But there is a difference between the moments with regard to intensity and the moments with regard to how the data is distributed spatially. You know the difference don't you? For example, consider two images, one with a Gaussian spot in the middle, and one with the Gaussian spot off-center. They will have the same intensity skewnesses but different spatial skewnesses. This is because the intensity skewness does not take location into account while the spatial skewness is like a moment of inertia (recall mechanics in your college physics class) and this of course depends on location. Just wanted to make sure you know the difference - if you already do, then just ignore what I said. Looks like you're after the intensity skewness, not the spatial skewness.
You didn't specify the problem but it's probably due to a display issue like Wayne pointed out. Otherwise you can use the debugger to set a breakpoint on the lines and examine the actual variables without regard to how they're printed out.
  1 件のコメント
rob
rob 2012 年 4 月 8 日
Hi Image Analyst, i totally forgot to look into this aspect. ALso, i did not know about the difference. You gave a very good explanation. I'm looking at skewness of a surface terrain, how the heights are distributed. So i'm looking at central moments, because that is how they are defined in regards to surface topography. Intensity skewness is what i'm going after.
I am trying to optimize my code now, which i'll do in night. I have a for loop running for a 1024*1200 matrix, which is very time consuming. I'll get back with the new code. Thank you Image Analyst. Have a Happy Easter.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by