Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does path retrieval work using imread and imwrite?

Tags:

image

matlab

I know how imread and imwrite works, but I don't know where do the function call the image file from? In other words, where do I store the image in order to call it using imread?

like image 423
noob88 Avatar asked Apr 17 '09 18:04

noob88


1 Answers

As Adam suggests you could change the Matlab working directory to the location of your images or what I tend to do is to get the user to select the file to be read using uigetfile

>> [fn,pn]=uigetfile({'*.TIFF,*.jpg,*.bmp','Image files'}, 'Select an image');
>> I = imread(fullfile(pn,fn));

or if you know the directory of to the images you want to read you could store it in a variable then you could get a list of images in that directory using dir

>> imageDir = 'c:\path\to\my\images';
>> imageList = dir(fullfile(imageDir,'*.tif')); % store all files with extension tif  
                                               % in a structure array imageList

from there you can loop through imageList and process each image found. Finally, you can use uigetdir to ask the user for the direcotory containing the image set.

like image 130
Azim J Avatar answered Oct 18 '22 01:10

Azim J