I Want Matlab code to cut ROI From the folowing medical image

1 view (last 30 days)
I Want Matlab code to cut ROI From the folowing medical image
  3 Comments

Sign in to comment.

Accepted Answer

JD GonGon
JD GonGon on 6 Feb 2016
I think you can use the following. I put some comments that you must read before execute.
%That first command give to you the option to select desired file, it is
%present .png file type in the selection, but if you want to open another
%file type you must select All files or one of the other options.
[file_name,cd_name]=uigetfile({'*.png;*''*.dcm;*''*.m; *.fig;*.mat;*.slx;*.mdl','MATLAB General files (*.m,*.fig,*.mat,*.slx,*.mdl)';
'*.png', 'pgn files (*.png)'; ...
'*.dcm', 'DICOM files (*.dcm)'; ...
'*.m', 'Code files (*.m)'; ...
'*.fig','Figures (*.fig)'; ...
'*.mat','MAT-files (*.mat)'; ...
'*.mdl;*.slx','Models (*.slx, *.mdl)'; ...
'*.mlappinstall', 'MATLAB App Installer (*.mlappinstall)';...
'*.rtw,*.tlc,*.tmf,*.c,*.cpp,*.h,*.mk,*.vhd,*.v', 'Code generator files (*.rtw,*.tlc,*.tmf,*.c,*.cpp,*.h,*.mk,*.vhd,*.v)';...
'*.prj', 'Deployment projects (*.prj)';...
'*.mn', 'MuPAD Notebook Files (*.mn)';...
'*.mu', 'MuPAD Program Files (*.mu)';...
'*.rpt', 'Report generator files (*.rpt)';...
'*.ssc', 'Simscape files (*.ssc)';...
'*.*', 'All Files (*.*)'}, ...
'Select a file to run the script',...
'Select a file');
cd (cd_name)
Image=imread(file_name);
figure, imagesc(Image),title('My image');
%When the image appears define clicking the ROI area, to finalize it, click
%over the first point and double click over the area periphery. Each click
%define a nodo for your desired area.
figure, imagesc(Image),mask=roipoly;
figure, imagesc(mask),title('Defined window')
normalized_Image=double(Image)./double(max(max(Image)));
Image_roi=normalized_Image.*mask;
figure,imagesc(Image_roi),title('ROI Image');
%That is a way to do that, if you want to restrict just a polygonal area
%you can also do the following comand. When imcrop figure appears, you must
%define area clicking and dragging and double clicking oer the area defined
%to extract area.
figure,
[img_restriction,rect]=imcrop(normalized_Image);
figure, imshow(img_restriction)
rect
% rect-> It is your defined area, if you want to apply this same size and
% localization to other image you can use that argument:
% img_new_image=imcrop(New_image,rect);

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!