我有一个二进制图像,我想删除白线大于阈值(如50像素)。如何在二值图像中去除大于阈值的白线? (matlab)
原始图像:
输入和输出的图像:
我的想法:
我要算位于每一个行,如果白色像素((白色像素数>阈值))然后删除该行。
请编辑和完成我的代码。
close all;clear all;clc;
I =imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/34446/1.jpg');
I=im2bw(I);
figure,
imshow(I);title('original');
ThresholdValue=50;
[row,col]=size(I);
count=0; % count number of white pixel
indexx=[]; % determine location of white lines which larger..
for i=1:col
for j=1:row
if I(i,j)==1
count=count+1; %count number of white pixel in each line
% I should determine line here
%need help here
else
count=0;
indexx=0;
end
if count>ThresholdValue
%remove corresponding line
%need help here
end
end
end
@Andy Jones我应该删除我的问题?我有一个problrm,有人帮我解决它。 –