Hi All,
Is there a way by which we can separate an image like this?
I would like to get an output like below.
I tried morphological operation but i could not and I am not sure that it is a true way.
Thanks in advance.

 採用された回答

Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 15 日

3 投票

clear; clc;
I = imread('tamp9f.png');
Icrop = imcrop(I);
bw = im2bw(Icrop);
imshow(bw); pause;
Ifill = imfill(bw,'holes');
imshow(Ifill); pause;
Iarea = bwareaopen(Ifill,10000);
imshow(Iarea); pause;
boundary = bwboundaries(Iarea);
b = boundary{1};
imshow(Ifill); hold on;
plot(b(:,2),b(:,1),'g','LineWidth',3);
The Result :

6 件のコメント

Nour
Nour 2014 年 12 月 19 日
Hi Dear Chandra, I would like to get an output similar than Bahar's one, but after the surrounding's done, I would like to cut the part surrounded which is a vehicle logo in my case.
I've tried your method for some hours, and then now I'm trying to edit it to see the results, but your help is welcome.
Thanks!
Nour.
Nour
Nour 2014 年 12 月 19 日
Image Analyst
Image Analyst 2014 年 12 月 20 日
Start your own question and I'll show you how. Attach your image there with the image or paper clip icon.
Nour
Nour 2014 年 12 月 20 日
Ok, i do it now.
Tx!
Image Analyst
Image Analyst 2014 年 12 月 20 日
An hour later, it still has not shown up. Try again.
Nour
Nour 2014 年 12 月 21 日
yeah just got that the post is not effective, i've just post it again, and it is ok now.
Thanks in advance!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2011 年 12 月 15 日

2 投票

Here's one of my functions that you might be able to use. It accepts a binary image and returns the "N" largest blobs in the output image.
% Retain the "numberToKeep" biggest blobs in a binary image.
function keeperBlobsImage = RetainLargestBlobs(binaryImage, numberToKeep)
try
% Label each blob so can do calc on it
[labeledImage numberOfBlobs] = bwlabel(binaryImage, 8);
% Make sure we don't attempt to keep more blobs than actually exist.
if numberToKeep > numberOfBlobs
numberToKeep = numberOfBlobs;
end
% Make the area measurements.
blobMeasurements = regionprops(labeledImage, 'Area'); % Get the blob properties of 'Area'
allAreas = [blobMeasurements.Area];
% Get a list of the blobs that meet our criteria and we need to keep.
[sortedAreas sortedIndices] = sort(allAreas, 'descend');
keeperIndexes = sortedIndices(1 : numberToKeep);
% Extract only those blobs that meet our criteria, and
% eliminate those blobs that don't meet our criteria.
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes);
catch ME
errorMessage = sprintf('Error in function RetainLargestBlobs.\n\nError Message:\n%s', ME.message);
WarnUser(errorMessage);
end
return; % from RetainLargestBlobs
Once you have the largest blob you can try to smooth the boundaries using alpha shapes ( http://cgm.cs.mcgill.ca/~godfried/teaching/projects97/belair/alpha.html ) or morphological methods such as alternating sequential filters ( http://www.esiee.fr/~coupriem/Pdf/cb04.pdf )

カテゴリ

ヘルプ センター および File ExchangeGeometric Transformation and Image Registration についてさらに検索

質問済み:

2011 年 12 月 15 日

コメント済み:

2014 年 12 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by