Problem with MATLAB imread ()

In my previous question, I asked about Blind Deconvolution in Matlab.

Now I have a new problem when I know how imreadand work imwrite, but I don’t know where this function is called from from the image file? in other words, where to store the image for calling with imread?

+3
source share
5 answers

As Adam suggests you change the Matlab working directory to the location of your images, or what I mean is to force the user to select a file to read withuigetfile

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

, , , , dir

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

imageList . , uigetdir, , .

+5

, IMREAD IMWRITE. , :

filePath = 'C:\mywork\matlab\images\picture1.jpg';

MATLAB "C:\mywork\matlab", ( ) :

filePath = 'images\picture1.jpg';

, , , - , . , Windows:

filePath = 'toolbox\matlab\iofun';

UNIX:

filePath = 'toolbox/matlab/iofun';

, , . , , MATLAB ( ): FULLFILE, FILEPARTS, FILESEP.

+2

imread() . , imread .

, , - :


imdir = 'C:\myproject\images\';
imfile1 = 'image1.jpg';
imfile2 = 'image2.jpg';

im1 = imread([imdir, imfile1]); im2 = imread([imdir, imfile2]);

, , .

+1

, Matlab , .

, ,

pwd

. cd . cd , . , , , dir .

, pushd popd - .

http://www.mathworks.com/matlabcentral/fileexchange/8103

Matlab , , , , uigetfile, . , : , . addpath, rmpath, savepath pathtool .

+1

Source: https://habr.com/ru/post/1706610/


All Articles