I Get error in imread
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abhijith Nuchin
le 22 Oct 2014
Réponse apportée : Image Analyst
le 22 Oct 2014
code:
image=uigetfile('*.bmp','Select the image');
B= imread(image, 'bmp'); figure(1),imshow(B);
Output
??? Error using ==> imread at 401 File "boat.bmp" does not exist.
Error in ==> Untitled3 at 3 B= imread(image, 'bmp');
The file exists..it takes input if i manually give filename, like this
A='C:\Users\Omkar\Desktop\boat.bmp'; B= imread(A, 'bmp'); figure(1),imshow(B);
0 commentaires
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 22 Oct 2014
Do not use image as the name of a variable - or else you will destroy a built-in function also called image. Also try not to turn your code into an alphabet soup of variables - use descriptive variable names, not just single letters or cryptic shorthand for everything. It will make your code more maintainable and understandable. See the much more robust code below:
% 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, '*.*');
[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 commentaires
Voir également
Catégories
En savoir plus sur MATLAB Support Package for USB Webcams dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!