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 Comment

You cannot get 3 errors. Matlab stops after the first. You see the calling stack of one error.

Sign in to comment.

Answers (1)

What does it report if you say
whos I1

2 Comments

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

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 19 Dec 2012

Community Treasure Hunt

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

Start Hunting!