Problem in finding the skewness for the blocks of an image

1 view (last 30 days)
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);

Accepted Answer

Image Analyst
Image Analyst on 4 Dec 2012
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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!