Problem in finding the skewness for the blocks of an image

1 回表示 (過去 30 日間)
Mohan
Mohan 2012 年 12 月 4 日
clc;
clear all;
close all;
b = imread('D:\PT\gund\image0006.png');
b1 = rgb2gray(b);
c = imresize(b1, [64 64]);
z = 1;
for m = 1:4:61
for n = 1:4:61
Q(:,:,z) = c(m:m+3,n:n+3);
z = z + 1;
end
end
% finding skewness
for z = 1 : 256
a = (Q(:,:,z));
skew_1(z,:) = skewness(a);
end
The above program shows the error Error using - Integers can only be combined with integers of the same class, or scalar doubles.
Error in skewness ( line 39) x0 = x - repmat(nanmean(x,dim),tile);
Error in mrk_skew(*line 23 ) skew_1(z,:) = skewness(a);

採用された回答

Image Analyst
Image Analyst 2012 年 12 月 4 日
Well, there's a lot of code missing from your program (like where you defined Q and skew_1), but generally that error shows up when you try to do something like add a uint8 array to a uint16 array. Why don't you just cast your image to floating point to avoid the problem:
c = double(imresize(b1, [64 64]));
I also don't understand your definition of skewness. It's the 3rd central moment of the histogram, like explained here: http://en.wikipedia.org/wiki/Skewness. I'm not seeing that in your code.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by