I Get error in imread
8 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (1)
Image Analyst
on 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 Comments
See Also
Categories
Find more on MATLAB Support Package for USB Webcams 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!