code to select a jpg image from a folder in matlab

조회 수: 29 (최근 30일)
Shweta Naiskar
Shweta Naiskar 2017년 3월 17일
답변: Image Analyst 2017년 3월 17일
code to select a jpg image from a folder in matlab
  댓글 수: 1
Rik
Rik 2017년 3월 17일
Have a read here and here. It will greatly improve your chances of getting an answer.
And in your case, type doc imread to find out more.

댓글을 달려면 로그인하십시오.

채택된 답변

sam  CP
sam CP 2017년 3월 17일
Use the folloswing code for selecting the jpg image from a folder
[filename pathname] = uigetfile({'*.jpg';'*.bmp'},'Select MRI'); inputimage=strcat(pathname, filename);

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 3월 17일
Try this:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = 'C:\Program Files\MATLAB';
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.jpg');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
theImage = imread(fullFileName);
But much more user friendly is to use a listbox where your users can simply click on the image they want. Why force them to deal with a tedious and cruel file-browse dialog box every time? Why be mean to your users? Make it EASY for them instead. See MAGIC: http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component

카테고리

Help CenterFile Exchange에서 Medical Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by