我有一個二進制圖像,我想刪除白線大於閾值(如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,有人幫我解決它。 –