dilation of specific objects

조회 수: 6 (최근 30일)
Mahalakshmi
Mahalakshmi 2011년 7월 11일
I am wondering if it is possible to perform dilation on a part of the image. Basically after converting the image to binary I have a number of objects. By using regionprops I have their area. Can I perform dilation only for those whose area<x using imdilate. If not imdilate is there a way I can do that? Thanx.

채택된 답변

Nathan Greco
Nathan Greco 2011년 7월 11일
First, I would label regions in your image:
bwl = bwlabel(img,8);
Area of regions:
a = regionprops(img,'area');
a = {a.Area}; %turn into cell array
Create a mask for what you want to be dilated:
xarea = 10;
idx = find(cellfun(@(x)x<xarea,a));
bwl2 = sum(reshape(cell2mat(arrayfun(@(x)x==bwl,idx,'un',0)),size(img,1),size(img,2),[]),3);
Dilate the mask:
bwl2 = bwmorph(bwl2,'dilate',1);
And finally, apply this dilated mask back to the original bw image:
img = img | bwl2;
  댓글 수: 2
Image Analyst
Image Analyst 2011년 7월 12일
Yikes! For a simpler way to extract the indicated region, you might use ismember:
bw12 = ismember(bwl, idx) > 0;
instead of that complicated sum() expression.
Mahalakshmi
Mahalakshmi 2011년 7월 12일
Thanx :).. It worked :) :)..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by