y = imread(file1, 'BackgroundColor', [1 1 1]); WHAT DOES IT DO?
Show older comments
I am getting an error in this line as:
Error using strfind
Input strings must have one row.
Error in getFileFromURL (line 8)
if (strfind(filenameIn, '://'))
Error in imread (line 327)
[isUrl, filename] = getFileFromURL(filename);
Error in oooo (line 63)
y = imread(I, 'BackgroundColor', [1 1 1]);
Answers (2)
dpb
on 26 May 2018
doc imread
Read image from graphics file
Syntax
A = imread(filename)
A = imread(filename,fmt)
A = imread(___,idx)
A = imread(___,Name,Value)
...
Description
A = imread(filename) reads the image from the file specified by filename, inferring the format of the file
from its contents. If filename is a multi-image file, then imread reads the first image in the file.
A = imread(filename,fmt) additionally specifies the format of the file with the standard file extension indicated
by fmt. If imread cannot find a file with the name specified by filename, it looks for a file named filename.fmt.
...
A = imread(___,Name,Value) specifies format-specific options using one or more name-value pair arguments,
in addition to any of the input arguments in the previous syntaxes.
...
Ergo, the first argument must be a valid filename string; you've passed what looks to be an array, I.
6 Comments
[OP's comment from Answer--dpb]
I is the name of the image file.. this image is extracted from a video and then saved in my computer. so I wrote
I = imread('Frame 0001.png')
And later in the code used as...
y = imread(file1, 'BackgroundColor', [1 1 1]);
Is something wrong with it?
dpb
on 26 May 2018
I = imread('Frame 0001.png');
is OK, yes. Now I is the immge array.
"And later in the code used as..."
y = imread(file1, 'BackgroundColor', [1 1 1]);
Well, whether that would be ok or not depends upon what variable file1 happened to hold at the time IF that were the actual code used.
But, what the error message says you used was
Error in oooo (line 63)
y = imread(I, 'BackgroundColor', [1 1 1]);
as taken directly from the error message, so you didn't use file1, you did, in fact, use I and you had, it appears, already read the image into I.
We don't have the preceding lines in the function or script oooo.m (a remarkably uninformative script name) so we can't see all the code, but clearly I was NOT a file name when that line was executed.
y = imread(I, 'BackgroundColor', [1 1 1]);
Walter Roberson
on 26 May 2018
If I were a file name you would still have a problem, because BackgroundColor is not a valid option to imread.
Ameer Hamza
on 26 May 2018
Walter Roberson
on 26 May 2018
Huh, so it is!
SURILA GUGLANI
on 27 May 2018
SURILA GUGLANI
on 27 May 2018
0 votes
1 Comment
Walter Roberson
on 27 May 2018
After you do
I = imread('Frame 0001.png') And later in the code used as...
then I is the content of Frame 0001.png , and is not a file name.
You would need something like
filename = 'Frame 0001.png';
I = imread(filename);
y = imread(filename, 'BackgroundColor', [1 1 1]);
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!