【问题标题】:what is problem in the following matlab codes以下matlab代码有什么问题
【发布时间】:2011-02-28 22:31:33
【问题描述】:
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

【问题讨论】:

  • 您需要更加具体 - 什么不起作用?
  • 函数矩形不起作用
  • 不工作怎么办?到目前为止你做了什么来调试它?

标签: matlab image-processing


【解决方案1】:

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

【讨论】:

  • 这可能会做到。调试的时候尽量不要把函数变成脚本。这可能会变得非常混乱。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-10
  • 2017-02-17
  • 1970-01-01
相关资源
最近更新 更多