0
$\begingroup$

I want to remove the portion of the line (highlighted by the yellow circles) where pixels form a straight vertical line segment.

enter image description here

If I use the strel

SE = strel('line', 5, 90); edgesR = imerode(In_R,SE);

then the remaining lines are also being erased.

Is there any other approach here?

$\endgroup$
  • 1
    $\begingroup$ Think the other way: create a structuring element that preserves those lines, and removes everything else (you’ll need to use an opening, not an erosion). The difference between the input and the opened image is everything except those lines. So make your SE shorter and use imopen. $\endgroup$ – Cris Luengo Oct 20 '18 at 16:38
0
$\begingroup$

This is a program which removes the line segments in a single column of length which is more than the threshold

function [ret_im] = remove_vertical(in_image)


[NZ_r, NZ_c] = find(in_image);

ori = in_image;

%scan through each row of location of non-zero pixels 
% If three (threshold) or more pixels are placed in a single column, turn them to zero
thresh = 3;
for i=1:1:size(NZ_r,1)-1

    probe = NZ_c(i); % Set the initial search element
    len = length(find(NZ_c(:)==probe));
    if( len > thresh)
        for j=1:1:len
            if((NZ_r(i+1) - NZ_r(i)) == 1)
                in_image(NZ_r(i),NZ_c(i)) = 0;
            end
        end
    end
end

ret_im = in_image;

end
$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.