0

I have the following image initial image and after I've converted it to binary binary image, I want in some way to keep only the 3 lines shown and remove the other objects. I've tried several things using region props etc in Matlab but I didnt manage to filter out these areas. Any idea?

Katerina T
  • 15
  • 5
  • 1
    The [documentation](https://www.mathworks.com/help/images/object-analysis.html?s_tid=CRUX_lftnav) has tutorials for two different techniques: Hough transform and Radon transform. I'd suggest starting there. – beaker May 13 '21 at 18:57
  • 1
    This question cannot be answered with so little description and a single sample image. If you only have that image to process, do it by hand with an image editor ! Otherwise, the solution will depend on the properties that can be relied on from case to case. (Notice that the "objects" are also made of straight lines (though shorter). –  May 13 '21 at 21:06
  • 1
    You've deleted your [previous question](https://stackoverflow.com/q/67487772/7328782) after receiving an answer. Please don't do that. It is rude and will get you question-banned. https://stackoverflow.com/help/someone-answers – Cris Luengo May 14 '21 at 15:53

1 Answers1

0

Hough transform may be the first way to refer, but in case you are not satisfied with results, you can try to use morphological opening with lines as structuring elements. Since your lines are directed to several different directions, you should try any possible directions and then merge yielding images. If you have a prior knowledge about directions, you can make use of it and filter by direction too.

An example code block may look like this:

my_img = imread('img.png'); % get your image here
opened=[];
se_length = 25; % chose in pixels, according to your need
for derece = 50:2:70 % use 0:3:180 for all directions
    se_line = strel('line', se_length, derece);
    opened = cat(3, opened, imopen(my_img, se_line));
end

max_opened = max(opened, [], 3); % merge images based on maximum (or your own method)

Morphological opening can be used to filter many shapes. Just select the structuring element according to your need. The above scripts give the following result for your specific image example:

opened and maximized image

mselmany
  • 116
  • 4