How can I remove white lines which is larger then Threshold value in binary image ? (matlab) -


i have binary image want remove white lines larger threshold value (like 50 pixel).

original image:

enter image description here

input , output image :

enter image description here

my idea:

i want count white pixels located in each rows , if (( number of white pixel > threshold value )) remove line.

please edit , complete code.

  close all;clear all;clc;    =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 larger..   i=1:col       j=1:row            if i(i,j)==1               count=count+1; %count number of white pixel in each line         % should determine line here         %need here           else               count=0;               indexx=0;           end           if count>thresholdvalue           %remove corresponding line           %need here           end       end   end 

there small part missing, must check if reached end of line:

    if count>thresholdvalue         %check if end of line reached         if j==row || i(i,j+1)==0             i(i,j-count+1:j)=0;         end     end 

updated code regarding comment:

i =imread(pp); 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 larger.. i=1:row %row , col swapped in loop     count=0; %count must retest @ beginning of each line      j=1:col %row , col swapped in loop          if i(i,j)==1             count=count+1; %count number of white pixel in each line             % should determine line here             %need here         else             count=0;             indexx=0;         end         if count>thresholdvalue             %check if end of line reached             if j==col || i(i,j+1)==0                 i(i,j-count+1:j)=0;             end         end     end end imshow(i) 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -