How to fullfill segmented region by using region growing?

Can anyone help me on how to make the segmented purple region fulfilled the neighborhood 'empty' area with the same purple color?
The image is actually an overlapped of two brain images: </matlabcentral/answers/uploaded_files/54479/overlapped%20images.png>
The problem is, how to make the region of purple growing and fulfill all it's neighborhood region so that the region is larger.
Actually my intention is to perform region growing before k-means clustering, but it seems like it does not make any sense because both are segmentation. Any idea guys?...

 Accepted Answer

The image is actuall
y an overlapped of two brain images:

2 Comments

I managed to solve the problem using this code:
% Find boundry of image
bw = im2bw(image, graythresh(image));
cc = bwconncomp(bw);
lblMatrix = labelmatrix(cc);
edgeMatrix=edge(lblMatrix,'roberts',0);
edgeMatrix1 = double(edgeMatrix);
edgeMatrix1(end, end, 3) = 0;
figure;
imshow(edgeMatrix1);
%fill inside the region of detected edge
edgeMatrix2=imfill (edgeMatrix1,'holes');
figure; imshow(edgeMatrix2); title('WM and WMH Boundary Extraction','FontSize', 12);
%overlay detected edge on segmented image
rgbImageX = imoverlay(hat, edgeMatrix1, [1 0 0]);
imshow(rgbImageX); title('Boundary overlay on segmented images','FontSize', 12);
iza
iza on 21 Jun 2016
Edited: iza on 21 Jun 2016
In order to crop the image by using the boundary, here is the code. By the way addImGMWM is RGB image.
%crop the image
% Create a binary image ("mask") from the ROI object.
figure;
imshow(bw);
title('Binary mask of the region', 'FontSize', fontSize);
% Mask the image.
rgbImage=addImGMWM;
maskedRgbImage = bsxfun(@times, rgbImage, cast(bw,class(rgbImage)));
% Display it.
figure;
imshow(maskedRgbImage);
title('Mask of the desired region only', 'FontSize', fontSize);

Sign in to comment.

More Answers (0)

Asked:

iza
on 17 Jun 2016

Edited:

iza
on 21 Jun 2016

Community Treasure Hunt

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

Start Hunting!