Is there some function in Matlab with which I can dilate only a small ROI in the image?

5 ビュー (過去 30 日間)
Bhavya Agarwal
Bhavya Agarwal 2011 年 2 月 7 日
Is there some function in Matlab with which I can dilate only a small ROI in the image?
  1 件のコメント
David Young
David Young 2011 年 2 月 7 日
It would be helpful to know how the ROI is defined, and whether it is rectangular or some other shape.

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

回答 (1 件)

Brett Shoelson
Brett Shoelson 2011 年 2 月 7 日
Actually, it doesn't really matter how the ROI is defined, nor what shape it is. The function roifilt2 makes it easy. Here's a code snippet that will allow you to define a freehand ROI, and then dilate the image only within the selected ROI.
img = imread('coins.png');
imshow(img)
roi = imfreehand;
mask = roi.createMask;
func = @(x) imdilate(x,strel('disk',10));
partiallyDilated = roifilt2(img,mask,func);
imshow(partiallyDilated)
Cheers,
Brett

Community Treasure Hunt

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

Start Hunting!

Translated by