MATLAB: I Get error in imread

image processing

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);

Best Answer

you just need to give the full path of your file
[filename,pathname]=uigetfile('*.bmp','Select the image');
B= imread(fullfile(pathname,filename), 'bmp');
figure(1);
imshow(B);