browse the computer to find image

3 次查看(过去 30 天)
Hi, I'm working with image processing and I can't find a code where, whenever I run the script, I can browse and choose the image on the computer, instead of changing my code.
I = imread('foto1.jpg');
res = quantSoja(I);
quantSoja() is a function I created for processing.
I want to replace "imread" with another command so that I can browse the computer.

采纳的回答

Image Analyst
Image Analyst 2021-12-29
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 = pwd; % or 'C:\wherever';
if ~isfolder(startingFolder)
% 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, '*.*'); % or *.jpg if you want to limit files shown to JPG files.
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
rgbImage = imread(fullFileName);
imshow(rgbImage);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by