Changing of image will result in error in code.

Whenever I change the jpg image name in the imread section (code attached below) the codes will fail to load, indicating that an error has occurred.
My codes:
--------------------------
clc;clear all;close all;
dat=[];
I1=imread('ab.jpg');
b=rgb2gray(I1);
[invmo]=invmoments(b);
features=[invmo];
dat=[dat ; features];
-----------------------------------
A total of 3 errors are present. The error reads like this:
(1st error)
Error using rgb2gray>parse_inputs (line 84)
MAP should be a double m x 3 array with values in the range [0,1]. Convert your map to double
using IM2DOUBLE.
(2nd error)
Error in rgb2gray (line 35)
X = parse_inputs(varargin{:});
(3rd error)
Error in invmoment (line 7)
b=rgb2gray(I1);
I ensured that that the new image file was in the same folder as the codes. As soon as i changed the image name to the original 1st file the codes run perfectly. I am puzzled as to why by just changing the image name the codes would not work. My goal was to run the same codes for other images but it don't work for some reason. Any guidance? Thanks.

댓글 수: 1

Jan
Jan 2012년 12월 19일
You cannot get 3 errors. Matlab stops after the first. You see the calling stack of one error.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2012년 12월 19일

0 개 추천

What does it report if you say
whos I1

댓글 수: 2

Speculation: the image is empty.
Can it return empty? Or would it just throw an exception?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2012년 12월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by