how to extract objects from an image after filling in the objects in the binary image

4 ビュー (過去 30 日間)
betty
betty 2021 年 11 月 21 日
回答済み: yanqi liu 2021 年 11 月 22 日
I need to delete the objects I have marked below from the binary image but I don't know how to do it can you help

回答 (3 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 11 月 21 日
編集済み: KALYAN ACHARJYA 2021 年 11 月 21 日
Original BW image
BW_result=bwareafilt(BW,2); % Get the largest 2 max size objects
result=~(BW_result.*BW); % Nand Logical Operation or do other as per requirements
  2 件のコメント
betty
betty 2021 年 11 月 21 日
thank you it was very useful :)
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 11 月 21 日
Welcome! Please change the logical operation as per your requirements

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


Image Analyst
Image Analyst 2021 年 11 月 21 日
How do you want to specify the objects? Like you're going to manually, interactively click on them? Or based on their size, shape, or location? What exactly indicates those two particular blobs in the image out of the 6 in there?
I mean one way is
[labeledImage, numShapes] = bwlabel(binaryImage);
extractedTwoShapes = ismember(labeledImage, [3, 5]);
but I doubt that's what you want to do.
  4 件のコメント
betty
betty 2021 年 11 月 21 日
I'm sorry I forgot to mention. We need to delete it by location.
Image Analyst
Image Analyst 2021 年 11 月 21 日
OK, you can use regionprops() to get both the centroids and bounding boxes. How are you defining the locations of blobs to delete? Like their centroid is in a certain box in your image? Or the edge of your bounding box is in some range?

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


yanqi liu
yanqi liu 2021 年 11 月 22 日
sir,may be use mask to filter the block,such as
clc; clear all; close all;
im=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/808264/image.jpeg');
im=imcrop(im,[82 117 519 518]);
bw = im2bw(im);
bt = bw;
bw1 = bwareafilt(bw, 1);
bw2 = bwareafilt(bw, 3);
bw2(bw1) = 0;
bw(logical(bw2)) = 0;
figure; imshow(bt);
figure; imshow(bw);

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by