【发布时间】:2014-09-04 00:23:27
【问题描述】:
我正在开发 gui 并使用 GUIDE。它加载并成像,并让用户在一个点周围绘制一个 ROI(粒子 ROI)。然后我想要两个滑块来创建第二个 ROI(扫描 ROI),用户可以在其中使用滑块设置第二个 roi 的宽度和高度,并在图像上看到它的更新。滑块似乎工作正常,但我的 gui 不断在图像上绘制一个新的 roi,所以看起来很快就会变得凌乱。我想在重绘之前从图像中删除用户相当大的 roi(同时仍将原始粒子 ROI 保留在图像上。我目前采用以下方式:
在 setroi 大小按钮的回调中(这应该是用于粒子 ROI)
handles=guidata(hObject);
particleroiSize=imrect;% - draw a rectagle around the particle to get a meausr eof ROI size
roiPoints=getPosition(particleroiSize); %-get tha parameters fo the rectanlge
partX1 = round(roiPoints(1));
partY1 = round(roiPoints(2));
partX2 = round(partX1 + roiPoints(3));
partY2 = round(partY1 + roiPoints(4)); % these are the ROi positions in pixels
roiHeight = round(roiPoints(3)); % - these are just the ROI width and height
roiWidth = round(roiPoints(4));
handles=guidata(hObject); %_ update all the handles...
handles.partX1=partX1;
handles.partX2=partX2;
handles.partY1=partY1;
handles.partY2=partY2;
handles.roicenterX = (partX1 + round(roiPoints(3))/2);
handles.roicenterY= (partY1 + round(roiPoints(4))/2);
handles.roiHeight = roiHeight;
handles.roiWidth = roiWidth;
current_slice = round(get(handles.Image_Slider,'Value'));
particleImage=handles.Image_Sequence_Data(partY1:partY2,partX1:partX2,current_slice);
handles.particleImage=particleImage;
set(handles.RoiSizeDisplay,'String',strcat('Particle ROI is ',' ',num2str(roiHeight),' ', ' by ',num2str(roiWidth)) );
guidata(hObject,handles);
然后在回调中设置我拥有的扫描 ROI 大小的滑块(这是在两个不同的滑块内,一个调整宽度,一个调整高度: 句柄=guidata(hObject);
try
delete(handles.ScanArea);
% plus any cleanup code you want
catch
end
WidthValue = get(handles.ScanAreaSliderWidth,'value');
HeightValue = get(handles.ScanAreaSliderHeight,'value');
set(handles.ScanAreaWidthDisplay,'String',strcat('Scan Area Width is ',' ', num2str(WidthValue))); % sets the display..now to do the drawing...
%h = imrect(hparent, position);
%position = [Xmin Ymin Width Heigth];
position = [ round(handles.roicenterX-WidthValue/2) round(handles.roicenterY-HeightValue/2) WidthValue HeightValue];
handles.ScanArea = imrect(handles.Image_Sequence_Plot,position);
%h = imrect(hparent, position)
handles=guidata(hObject);
guidata(hObject, handles);
但它永远不会删除扫描区域的 ROI 并不断对其进行重绘..我认为 try...catch 会起作用,但似乎没有。我是在制作额外的 ROI 副本还是什么?请帮忙.. 谢谢。
【问题讨论】:
标签: matlab image-processing matlab-guide roi