【发布时间】:2015-05-04 11:38:08
【问题描述】:
我正在尝试进行动态阈值处理,但出现了一些错误。我正在尝试适应这段代码:http://www.inf.ed.ac.uk/teaching/courses/ivr/lectures/ivr5hand.pdf
function [Output ] = dinamicthresh()
[filename,pathname] = uigetfile('*.bmp; *.jpg', 'Please select an image file');
I=fullfile (pathname,filename);
I=imread(I);
I=rgb2gray(I);
I=im2double(I);
[H,W]= size(I);
Output= zeros(H,W);
halfH=round(H/2);
halfW=round(W/2);
for i= H:H
for j = W:W
C = I(i-halfH:i+halfH,j-halfW:j+halfW);
adaptative_thresh = mean(mean(C)) - 12;
if I(i,j) < adaptative_thresh
Output(i,j)= 1;
else
Output(i,j)= 0;
end
end
end
subplot(1,2,1);imshow(I);title('Original Image');
subplot(1,2,2);imshow(Output);title('Adaptive Thresholding');
end
【问题讨论】:
-
您能否提供一些有关您收到的错误以及代码的哪一部分给您错误的信息?
-
您的
for循环范围为H:H和W:W...每个循环执行一次。这看起来很可疑。我希望像1:H和1:W这样的东西。
标签: image algorithm matlab threshold adaptive-threshold