How to remove specific line in the binary image?

Hi! I'm a student who study MATLAB my own.
In the image below I want to remove the connected lines that the red arrow points to and leave only the lines in the yellow box.
The final thing I want to do is count the number of pixels in the yellow box, so we will use the regionprops function.
I am wondering if there is a way to remove the connected lines pointed to by the yellow arrow and get the count when using the regionprops function.
I would be grateful if the experts would help me a little.
Thanks.

1 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 8 月 13 日
attached the unedited binary image?

サインインしてコメントする。

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 8 月 13 日
編集済み: KALYAN ACHARJYA 2018 年 8 月 13 日

0 投票

Try this one, before applying the operation to convert the image to binary
binary_resultant=bwareaopen(binary_image,p)
% p Blob size, you can adjust accordingly
Image Analyst
Image Analyst 2018 年 8 月 13 日
編集済み: Image Analyst 2018 年 8 月 13 日

0 投票

It looks like you might have used bwboundaries to get the boundaries of the blobs, and that you don't want the interior boundaries. If that's the case, simply use imfill() before you call bwboundaries():
binaryImage = imfill(binaryImage, 'holes');
boundaries = bwboundaries(binaryImage);
or, more simply:
boundaries = bwboundaries(binaryImage, 'noholes');
if you don't want to change your binary image.
If you just want to mask out (erase to black) everything in the yellow box, simply make a mask and use it as an index
% Create the mask.
yellowBox = true(size(binaryImage));
yellowBox(row1:row2, col1:col2) = false;
% Do the masking.
maskedImage = grayImage; % Initialize a new copy.
maskedImage(yellowBox) = 0; % Erase outside the yellow box.
Of course you'll need to define the starting and stopping rows and columns.

1 件のコメント

YOUNG HYUN KIM
YOUNG HYUN KIM 2018 年 8 月 13 日
Thanks for your answer, Image Analyst!!!
I use below codes to get that image.
off1=imread('01.bmp');
eoff1=edge(off1,'Canny');
noff1=regionprops(eoff1, 'Area');
The Image that i attached on my question is the overlay image.
(use foff1=imoverlay(off1,eoff1,[0 1 0]))
In this code, how can i apply those code that you showed? Thanks.
I attatch a new figure 01.bmp!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

質問済み:

2018 年 8 月 13 日

コメント済み:

2018 年 8 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by