直方图特征中的计算错误

时间:2014-11-20 12:55:04

标签: matlab image-processing histogram

我得到的峰值只有251块,因为我把图像划分为块我没有得到什么错误实际它应该显示252块,请提前检查代码

clear all;
close all;

x =  imread('image009.png');
rgb = imresize(x,0.5);
green  = rgb(:,:,2);
[m,n]=size(green);
imnum=input('enter image number');
g=1;
q=1;
scaler=36;
scalec=37.5;
bno=1;
g=1;

for i=1:scaler:(m-scaler)
    if((i==1)||(i==(m-scaler))
        continue;    
    end

    for j=1:scalec:(n-scalec)

        if((j==1)||(j==(n-scalec)))
            continue;
        end
        tbpcolr = imcrop(green,[j,i,scalec,scaler])
        ip=input('press some key');
        mgreen = mean2(tbpcolr);
        stats = hisfeatures(tbpcolr);
        Mean(1,g) = stats(1)
        Variance(1,g) =stats(2)
        Skewness(1,g) =stats(3)
        Kurtosis(1,g)=stats(4)
        Energy(1,g) =stats(5)
        Entropy(1,g) =stats(6)
        Kurtosis = Kurtosis(~isnan(Kurtosis))
        Entropy = Entropy(~isnan( Entropy))
        Skewness = Skewness(~isnan(  Skewness))
        g=g+1;
        bno=bno+1; 
    end
end

blockno = [];
for  i = 1:252
    blockno(i)=i;
end

for  i = 1:252
    result_his=vertcat(Energy,Mean,Variance,Kurtosis,Skewness,Entropy,blockno); 
end

result_his=result_his.'

1 个答案:

答案 0 :(得分:0)

用NaN去除细胞会破坏基质结构。删除包含NaN的整行将丢弃实际数据。相反,统计工具箱具有与其他MATLAB函数类似的各种函数,但是将NaN值视为缺失,因此在计算中忽略它们。