Strange problem with "imread" function

4 ビュー (過去 30 日間)
Subham Verma
Subham Verma 2018 年 7 月 28 日
コメント済み: Subham Verma 2018 年 8 月 1 日
Hello,
I am getting a strange issue while trying to use imread function to read an image. It works perfectly fine for case 1 (see 1.png which I have attached). But when I try to do the same with case 2(see 2.png which I have attached) it gives me error. What can be cause and the solution? I have also tried num2str() but it does not solve the issue.
Thanking you in advance.
  1 件のコメント
Jan
Jan 2018 年 7 月 28 日
Please post code and error as text, not as screen shots.

サインインしてコメントする。

採用された回答

Jan
Jan 2018 年 7 月 28 日
編集済み: Jan 2018 年 7 月 28 日
In the second case the code is:
image = imread(img);
...
I = imread(image);
This means, that image is the imported image already and using it as input for another imread call must fail with the shown error message.
You can find such problems easily using the debugger. See Doc: Debugger. Set a breakpoint in the failing line. Alternatively let Matlab stop automatically when the error occurs. Type this in the command window:
dbstop if error
Then let the code run again. When it stops, check the values of the variables:
class(image)
You will see, that it is not an appropriate input for imread, exactly as the error message tells already.
  1 件のコメント
Subham Verma
Subham Verma 2018 年 8 月 1 日
Thank you

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 7 月 28 日
Do not use image as the name of your image. It's the name of a built-in function. Also, do not use I - it looks too much like 1 (one) or l (lower case L).

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by