views:

300

answers:

2

I have to use Matlab to read a picture and make a joint histogram and I'm new to Matlab. When I try to read the Image by using imread function it does not work.

h= imread('a.tif');
??? Error using ==> imread at 363
File "a.tif" does not exist.

Can anyone help me figure out this problem?

+2  A: 

Perhaps a.tif doesn't exist, or is located in the wrong directory ?

Paul R
how can I fix this problem ,PLZ
looolo
Check that (a) file a.tif exists and (b) that it is located in the correct directory.
Paul R
I saved a.tif in the disk top
looolo
Since you didn't specify a path to the file then it needs to be in MATLAB's working directory (probably the same directory as where your .m file resides). Alternatively you can just specify a full (absolute) path to the .tif file.
Paul R
you can navigate to the correct directory using the usual `cd 'path/to/dir'`, also you can check the current directory using `pwd`
Amro
imread should be able to find the file 'a.tif' anywhere in your Matlab path. If the file is located under 'C:\', use "addpath('C:\')" on the Matlab console before running your code
Wolfgang Ulmer
I solve it the problem from matlab virsion
looolo
+2  A: 

One easy way to make sure you have the right path and file name is uigetfile.

To determine your path and filename, use

 [filename,path]=uigetfile();

Then modify the code you have written to include the path as well. (If you're new to MATLAB, the syntax for combining two string arrays is [str1, str2])

Doresoom

related questions