Image Processing​-imfreehan​d-Saving the line

1 次查看(过去 30 天)
I would like to know if there is a way to save the line aftter using imfreehand function in order to recall it in the same picture someother time .More specifically here is the code it is the callback by a pushbutton i have in my GUI :
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Matlab knows where to plot the data
axes(handles.axes10)
I=imshow(handles.Seg,'Displayrange',[]);
%where handles.seg is the grayscale image of a cancer area
h=imfreehand
handles.posTelaplo=getPosition(h);
%saving the position
handles.BW = createMask(h,I);
% imshow(BW);
[teliko mpla]=perim(handles.tumor,handles.BW
%perim is a function that generates the line made by imfreehand (the perimeter of cancer area)
imshow(teliko,'Displayrange',[]);
%showing the image along with the line made by imfreehand that surrounds the cancer area
guidata(hObject,handles)
i would like to do something like this but i dont know what i should save and how excactly ,meaning in which form in order to recall it :
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Matlab knows where to plot the data
axes(handles.axes10)
I=imshow(handles.Seg,'Displayrange',[]);
button5=questdlg('Would you like to draw a new region or use a previous one?','Freehandselection','Draw new region','Use a previous','No');
if size(button5,2) > 12
** (?can i do that or should i put just one string with" _" in between?)**
I=imshow(handles.Seg,'Displayrange',[]);
h=imfreehand;
handles.posTelaplo=getPosition(h);
handles.BW = createMask(h,I);
imshow(BW);
[teliko mpla]=perim(handles.tumor,handles.BW);
imshow(teliko,'Displayrange',[])
button3 = questdlg('Do you want to save the area that you marked in order to use it another time?','Save freehand area','Yes','No','No');
if size(button3,2) > 2
%HERE I WOULD LIKE TO SAVE THIS LINE OR AREA and run again perhaps the perim function
else
%dont do nothing
end
else
* * HERE i would like to recall the saved line /area ,for the image that is used (perhaps saved together in a way ?)**
end
guidata(hObject,handles)
* Thanks in advance.*

回答(1 个)

Image Analyst
Image Analyst 2012-6-1
Don't use bwperim(). Use bwboundaries() to get the x,y coordinates. Then use save() and load() to save or recall via a .mat file.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by