How to fill the regions within the traced boundry using "bwboundaries"

Hi, I am using bwboundaries to trace the boundaries. I want to know,how to fill the traced region alone with white pixels.

 採用された回答

Dishant Arora
Dishant Arora 2014 年 2 月 19 日
編集済み: Dishant Arora 2014 年 2 月 19 日

0 投票

b=imfill(b,'holes');

4 件のコメント

BAKIYA LAKSHMI
BAKIYA LAKSHMI 2014 年 2 月 19 日
Sir,I want to analyze only the pixels within the traced region. So I am need to create a binary mask of the traced region among other regions. This imfill fills the entire binary region not only the traced region.
Dishant Arora
Dishant Arora 2014 年 2 月 19 日
b=bwboundaries(bw); % bw is your binary image you want to operate on
binaryMask=false(size(bw));
for i = 1:length(b)
for j = 1:length(b{i})
ind = b{i}(j,:);
binaryMask(ind(1),ind(2))=1;
end
end
figure
imshow(binaryMask)
hopethis is what you are looking for.
BAKIYA LAKSHMI
BAKIYA LAKSHMI 2014 年 2 月 19 日
Thank you sir @ Dishant Arora. This code gives boundary binary mask,is it possible to fill the region within the boundary likewise?
Dishant Arora
Dishant Arora 2014 年 2 月 19 日
imfill will do.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 2 月 19 日

0 投票

filledImage = poly2mask(xBoundaries, yBoundaries, rows, columns);

6 件のコメント

Image Analyst
Image Analyst 2014 年 2 月 19 日
Since you must already have the binary image, why use bwboundaries if all you want to do is to fill holes. You can do
filledImage = imfill(binaryImage, 'holes');
No call to bwboundaries() is needed, unless you need it for some other reason.
BAKIYA LAKSHMI
BAKIYA LAKSHMI 2014 年 2 月 19 日
Since 'bwboundries' gives only the boundary pixels in a cell array format,I cant to able to segment it seperately. To proceed further I am in need to create binary mask to that traced region alone.
Image Analyst
Image Analyst 2014 年 2 月 19 日
I don't understand. You need a binary image FIRST to even call bwboundaries. Please attach your image.
BAKIYA LAKSHMI
BAKIYA LAKSHMI 2014 年 2 月 19 日
編集済み: Image Analyst 2014 年 2 月 19 日
close all;
clear all;
clc;
im=imread('E:\brain images\T2 ABNORMAL BRAIN\P1\image12.jpg');
im1=rgb2gray(im);
im2=medfilt2(im1,[3 3]);
F=imclearborder(im2,4);
J=imadjust(F);
BW=im2bw(im2);
BW=bwareaopen(BW,50);
figure(1),imshow(BW);
[B,L,N,A] = bwboundaries(BW);
for i=1:length(B);
k=i;
BW=bwareaopen(BW,50);
boundary = B{k};
J=imadjust(F);
v=im2uint8(BW);
J=im2uint8(J);
H=v-J;
figure,imshow(H,[]);
hold on
plot(boundary(:,2),...
boundary(:,1),'r','LineWidth',2);
hold off
end
Dishant Arora
Dishant Arora 2014 年 2 月 19 日
@Image analyst,I guess she probably wants a binary mask having 1's only at boundary positions.
Image Analyst
Image Analyst 2014 年 2 月 19 日
For that they'd use bwperim(). I ran the code and it does an auto-threshold and then gets the boundaries of all the regions. If that is not wanted then I need to know what is wanted. I have not heard a really clear explanation of what is wanted. I don't even know what a traced region is, as opposed to a regular connected components region that you get from thresholding. Perhaps a figure showing what the desired outcome is would be helpful if explaining it in English is difficult because English is not the native language of the poster. I'm pretty sure what is wanted is trivial if I could just understand what is wanted.

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

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by