Filter löschen
Filter löschen

How to fill a ROI without affecting outside?

3 Ansichten (letzte 30 Tage)
Steven
Steven am 17 Dez. 2013
Kommentiert: Neda am 15 Nov. 2017
Hi
I want to specify an ROI (of a binary image) on screen (several times) and make its inside white but do not change the outside. How can I do so?
I used imfill, but it gives me only the choice of choosing one point.
How can I determine the locations (specified by the user on screen) for imfill?
I tried to use this simple code, but it does not do what I want:
Image=binaryImage;
ROI = imfreehand();
ROI_xy = floor(hFH.getPosition)
Image(ROI_xy)=1;
I also used
Image=imfill(Image,ROI_xy);
but it didn't work either.
Could someone help me please with this?
Thanks. Steven

Akzeptierte Antwort

Image Analyst
Image Analyst am 17 Dez. 2013
I thought I already showed you in a prior question where I attached my demo (attached again). Anyway, you need to get the binary mask:
hFH = imfreehand();
% Create a binary image ("mask") from the ROI object.
binaryImage = hFH.createMask();
Then use it to make the image white:
grayImage(binaryImage) = 255;
By the way, don't use Image as the name of a variable since image is the name of a built-in function and it will be confusing.
  1 Kommentar
Neda
Neda am 15 Nov. 2017
I tried this to make a mask, but imfreehand isn't enough for me as it's not giving me the exact shape I need. any advice and suggestions will be greatly appreciated.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by