以下matlab代码中有什么问题

时间:2010-06-07 22:45:27

标签: matlab image-processing

img=imread('img27.jpg');

%function rectangle=rect_test(img)

% edge detection

[gx,gy]=gradient(img); 

gx=abs(gx);
 gy=abs(gy);
g=gx+gy;

g=abs(g);

% make it 300x300

img=zeros(300);

s=size(g);

img(1:s(1),1:s(2))=g;

figure; 
imagesc((img));
 colormap(gray);
 title('Edge detection')


% take the dct of the image

IM=abs(dct2(img));
figure;
 imagesc((IM));
 colormap(gray); 
title('DCT')

% normalize

m=max(max(IM)); IM2=IM./m*100;

% get rid of the peak

size_IM2=size(IM2);
IM2(1:round(.05*size_IM2(1)),1:round(.05*size_IM2(2))) = 0;

% threshold
L=length( find(IM2>20)) ;


if( L > 60 )
   ret = 1;
else
   ret = 0;
end

1 个答案:

答案 0 :(得分:2)

我想如果取消注释行function rectangle=rect_test(img),该功能将不起作用。这很可能是因为在您的函数中,永远不会定义变量rectangle。可能你想写ret=rect_test(img)而不是。