Hiding the drag points on a Matlab images.roi.Circle, and other ways of using ROIs as selection masks
Hello All,
TLDR at bottom
This question applies more broadly to the new Matlab images.roi objects, but I realized that the ROI’s are ideally set up to create selection bit-masks in an image. I can throw some arbitrary graphic into a figure, put an ROI below it, and use the ROI interface to determine when I mouse-over and click on that region. Depending on my needs I could also make my inset area draggable and stretchable depending on how I link in my ROI’s callbacks for movingROI and roiMoved. If I wanted to rebuild Myst in Matlab, this is how I would do it.
However, the sticky wicket is that you cannot as far as I can tell make an invisible ROI; the current format insists on drawing a border, and for some ROI objects it forces the appearence of drag points. Here is an example:
I = imread(‘cameraman.tif’);
imshow(I);
ax = gca;
circ = images.roi.Circle(ax,’Position’,[114 60],’Radius’,30);
Ok, so I have a nice circle ROI centered on the camerman’s head. I can make the center invisible via
set(circ,’FaceAlpha’,0)
However, both the border and the drag points are still visible: I cannot find a property or method to disable them!
Well, I can always set the circle to be invisible
set(circ,’visible’,’off’);
BUT this not only makes the circle visibly vanish, but also means that all of the interactions it came with are not accessible; I can only translate/etc the ROI programattically, not through the UI. Thus it makes a really poor selection mask.
I hoped that another option would be to limit us to translation:
set(circ,’InteractionsAllowed’,’translate’);
Thus, the drag points are no longer necessary…but they are still visible!
Ok, so I do know that it is possible to hide the drag markers, using
set(circ,’InteractionsAllowed’,’none’);
BUT, again this makes my ROI useless, as I cannot interact with it in any way.
I thought I had a genius moment, and added a listener that would only enable interactions when the ROI was selected:
addlistener(circ, ‘ROIClicked’, @(s,evtData) selectListener(s,evtData));
function selectListener(s,evtData)
selectedPart = evtData.SelectedPart
prevselected = evtData.PreviousSelected
if selectedPart && ~prevselected
set(circ,’InteractionsAllowed’,’Translation’);
else
set(circ,’InteractionsAllowed’,’none’);
end
Once again…failure. I cannot select an ROI with no interactions allowed; the istener is never called. I have to allow translations, stretching, or both.
This causes other potential issues, if I want to programattically draw an ROI and have some callback when selected but not allow moving the ROI, I have to lock the ROI in place using the movingROI callback rather than simply disabling the two movements; there should be a "no movement, but allow selection" setting, but I digress.
One kludge does let me at least get rid of the hideous drag buttons, but still leaves the outline (and is just plain dumb):
msk = images.roi.Freehand(ax,’Position’,circ.Vertices,’Waypoints’,false(size(circ.Vertices,1),1),’FaceAlpha’,0,’LineWidth’,.1);
delete(circ);
———————————————-
TLDR – I want to create an invisible but still interactable ROI using the images.roi toolbox. This requires hiding the outline and the drag points. I cannot do this and retain interactability. Is there a workaround?
Cheers,
-Dan
———————————————
P.S. I really dislike p-code. I understand the reason for it, but not being able to change simple properties and behaviors (such as making the drag points invisible) and not being able to figure out why is infuriating.Hello All,
TLDR at bottom
This question applies more broadly to the new Matlab images.roi objects, but I realized that the ROI’s are ideally set up to create selection bit-masks in an image. I can throw some arbitrary graphic into a figure, put an ROI below it, and use the ROI interface to determine when I mouse-over and click on that region. Depending on my needs I could also make my inset area draggable and stretchable depending on how I link in my ROI’s callbacks for movingROI and roiMoved. If I wanted to rebuild Myst in Matlab, this is how I would do it.
However, the sticky wicket is that you cannot as far as I can tell make an invisible ROI; the current format insists on drawing a border, and for some ROI objects it forces the appearence of drag points. Here is an example:
I = imread(‘cameraman.tif’);
imshow(I);
ax = gca;
circ = images.roi.Circle(ax,’Position’,[114 60],’Radius’,30);
Ok, so I have a nice circle ROI centered on the camerman’s head. I can make the center invisible via
set(circ,’FaceAlpha’,0)
However, both the border and the drag points are still visible: I cannot find a property or method to disable them!
Well, I can always set the circle to be invisible
set(circ,’visible’,’off’);
BUT this not only makes the circle visibly vanish, but also means that all of the interactions it came with are not accessible; I can only translate/etc the ROI programattically, not through the UI. Thus it makes a really poor selection mask.
I hoped that another option would be to limit us to translation:
set(circ,’InteractionsAllowed’,’translate’);
Thus, the drag points are no longer necessary…but they are still visible!
Ok, so I do know that it is possible to hide the drag markers, using
set(circ,’InteractionsAllowed’,’none’);
BUT, again this makes my ROI useless, as I cannot interact with it in any way.
I thought I had a genius moment, and added a listener that would only enable interactions when the ROI was selected:
addlistener(circ, ‘ROIClicked’, @(s,evtData) selectListener(s,evtData));
function selectListener(s,evtData)
selectedPart = evtData.SelectedPart
prevselected = evtData.PreviousSelected
if selectedPart && ~prevselected
set(circ,’InteractionsAllowed’,’Translation’);
else
set(circ,’InteractionsAllowed’,’none’);
end
Once again…failure. I cannot select an ROI with no interactions allowed; the istener is never called. I have to allow translations, stretching, or both.
This causes other potential issues, if I want to programattically draw an ROI and have some callback when selected but not allow moving the ROI, I have to lock the ROI in place using the movingROI callback rather than simply disabling the two movements; there should be a "no movement, but allow selection" setting, but I digress.
One kludge does let me at least get rid of the hideous drag buttons, but still leaves the outline (and is just plain dumb):
msk = images.roi.Freehand(ax,’Position’,circ.Vertices,’Waypoints’,false(size(circ.Vertices,1),1),’FaceAlpha’,0,’LineWidth’,.1);
delete(circ);
———————————————-
TLDR – I want to create an invisible but still interactable ROI using the images.roi toolbox. This requires hiding the outline and the drag points. I cannot do this and retain interactability. Is there a workaround?
Cheers,
-Dan
———————————————
P.S. I really dislike p-code. I understand the reason for it, but not being able to change simple properties and behaviors (such as making the drag points invisible) and not being able to figure out why is infuriating. Hello All,
TLDR at bottom
This question applies more broadly to the new Matlab images.roi objects, but I realized that the ROI’s are ideally set up to create selection bit-masks in an image. I can throw some arbitrary graphic into a figure, put an ROI below it, and use the ROI interface to determine when I mouse-over and click on that region. Depending on my needs I could also make my inset area draggable and stretchable depending on how I link in my ROI’s callbacks for movingROI and roiMoved. If I wanted to rebuild Myst in Matlab, this is how I would do it.
However, the sticky wicket is that you cannot as far as I can tell make an invisible ROI; the current format insists on drawing a border, and for some ROI objects it forces the appearence of drag points. Here is an example:
I = imread(‘cameraman.tif’);
imshow(I);
ax = gca;
circ = images.roi.Circle(ax,’Position’,[114 60],’Radius’,30);
Ok, so I have a nice circle ROI centered on the camerman’s head. I can make the center invisible via
set(circ,’FaceAlpha’,0)
However, both the border and the drag points are still visible: I cannot find a property or method to disable them!
Well, I can always set the circle to be invisible
set(circ,’visible’,’off’);
BUT this not only makes the circle visibly vanish, but also means that all of the interactions it came with are not accessible; I can only translate/etc the ROI programattically, not through the UI. Thus it makes a really poor selection mask.
I hoped that another option would be to limit us to translation:
set(circ,’InteractionsAllowed’,’translate’);
Thus, the drag points are no longer necessary…but they are still visible!
Ok, so I do know that it is possible to hide the drag markers, using
set(circ,’InteractionsAllowed’,’none’);
BUT, again this makes my ROI useless, as I cannot interact with it in any way.
I thought I had a genius moment, and added a listener that would only enable interactions when the ROI was selected:
addlistener(circ, ‘ROIClicked’, @(s,evtData) selectListener(s,evtData));
function selectListener(s,evtData)
selectedPart = evtData.SelectedPart
prevselected = evtData.PreviousSelected
if selectedPart && ~prevselected
set(circ,’InteractionsAllowed’,’Translation’);
else
set(circ,’InteractionsAllowed’,’none’);
end
Once again…failure. I cannot select an ROI with no interactions allowed; the istener is never called. I have to allow translations, stretching, or both.
This causes other potential issues, if I want to programattically draw an ROI and have some callback when selected but not allow moving the ROI, I have to lock the ROI in place using the movingROI callback rather than simply disabling the two movements; there should be a "no movement, but allow selection" setting, but I digress.
One kludge does let me at least get rid of the hideous drag buttons, but still leaves the outline (and is just plain dumb):
msk = images.roi.Freehand(ax,’Position’,circ.Vertices,’Waypoints’,false(size(circ.Vertices,1),1),’FaceAlpha’,0,’LineWidth’,.1);
delete(circ);
———————————————-
TLDR – I want to create an invisible but still interactable ROI using the images.roi toolbox. This requires hiding the outline and the drag points. I cannot do this and retain interactability. Is there a workaround?
Cheers,
-Dan
———————————————
P.S. I really dislike p-code. I understand the reason for it, but not being able to change simple properties and behaviors (such as making the drag points invisible) and not being able to figure out why is infuriating. image processing, rois, uix, p-code, images.roi.circle, get that drag point off my circle! MATLAB Answers — New Questions