Reading an image from path stored in a text file using IMREAD

I want to use imread() for reading an image by giving the path stored in a text file, given as input argument. I get an error saying Error in ==> imread at 199 if (strfind(filename, '://'))
WHAT SHALL BE DONE TO GET IT THROUGH?
the code is
fid=fopen('d:/output.txt','r'); data_line = fgetl(fid); data_line [a b] = strread(data_line, '%s %s', 'delimiter', ','); fclose(fid);
% where a and b are the paths i.e d:\pic\image_3.bmp and d:\pic\image_2.bmp
m1 = imread(a); m2 = imread(b);

1 Commento

what's inside a and b after the strread function?
(just remove the ; after the strread function and look at the results in the command line)

Accedi per commentare.

 Risposta accettata

fid=fopen('d:/output.txt','r');
data_line = textscan('%s%s', 1, 'delimiter', ',');
fclose(fid);
a = data_line{1}{1}; b = data_line{1}{2}; %I think

2 Commenti

Dear Walter
thank you very much for your kind consideration
after doing as you said, error is
??? Error using ==> textscan
First input must be of type double.
looking forward
Imran
dear walter
thanks alot you are great, it worked. You missed fid as first argument,rest its working now
great you are genius
Imran

Accedi per commentare.

Più risposte (1)

@Paulo Silva we have location in a and b like a=d:\pic\image_3.bmp and b=d:\pic\image_4.bmp
@Dear Walter thank you very much for your kind consideration after doing as you said, error is ??? Error using ==> textscan First input must be of type double.
Do you suggest something else looking forward Imran

Categorie

Scopri di più su Convert Image Type in Centro assistenza e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by