Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
error in imread

Subject: error in imread

From: astro mmi

Date: 15 Sep, 2010 18:25:05

Message: 1 of 5

Hi evryone.,
   This is a segment of the program I am writing. This is basically to create a grating as in MRI images for comparison of many different images.

mri = uint8(zeros(128,128,1,19));
%
for frame = 1:19 % Read all frames into mri
    [mri(:,:,:,frame), map ] = imread('cropped.jpg',frame);
end
montage(mri, map);

I am getting the following error when i rn he program.
"Error using ==> imagesci\private\readjpg
Too many input arguments.

Error in ==> imread at 389
    [X, map] = feval(fmt_s.read, filename, extraArgs{:});

Error in ==> bmip1 at 40
    [mri(:,:,:,frame), map ] = imread('cropped.jpg',frame);"

My image sizeis 128*128 and is grayscale. When I run the same segment with the built in image mri.tif, the segment works. Pls help and thanx in advance.

Subject: error in imread

From: ImageAnalyst

Date: 15 Sep, 2010 18:43:22

Message: 2 of 5

And why are you passing in frame as a second argument to imread()?
That is not an allowed input argument.

Also, if your image is grayscale, then why are you creating a 4D array
from 19 gray scale images (presumably you're going to change the
filename too), instead of a 3D image?

Subject: error in imread

From: astro mmi

Date: 15 Sep, 2010 21:09:05

Message: 3 of 5

Hi.,
   This segment of the code as I mentioned earlier works fine with mri.tif which is inbuilt. I am trying to do the same with my image and am not able to understand why I am getting this error. Even mri.tif is a 2-D grayscale image and when I input the frame as a second argument to imread, it accepts it. I am not able to understand where the mistake lies. Pls help and thanx in advance.


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <16e93ac8-b165-4f65-a24f-887f2a87c90e@w4g2000vbh.googlegroups.com>...
> And why are you passing in frame as a second argument to imread()?
> That is not an allowed input argument.
>
> Also, if your image is grayscale, then why are you creating a 4D array
> from 19 gray scale images (presumably you're going to change the
> filename too), instead of a 3D image?

Subject: error in imread

From: someone

Date: 15 Sep, 2010 21:25:08

Message: 4 of 5

"astro mmi" <pyarsa_madhu@yahoo.co.in> wrote in message <i6rclh$8t5$1@fred.mathworks.com>...
> Hi.,
> This segment of the code as I mentioned earlier works fine with mri.tif which is inbuilt. I am trying to do the same with my image and am not able to understand why I am getting this error. Even mri.tif is a 2-D grayscale image and when I input the frame as a second argument to imread, it accepts it. I am not able to understand where the mistake lies. Pls help and thanx in advance.
>
>
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message <16e93ac8-b165-4f65-a24f-887f2a87c90e@w4g2000vbh.googlegroups.com>...
> > And why are you passing in frame as a second argument to imread()?
> > That is not an allowed input argument.
> >
> > Also, if your image is grayscale, then why are you creating a 4D array
> > from 19 gray scale images (presumably you're going to change the
> > filename too), instead of a 3D image?

doc imread

% For TIFF files, imread accepts a second input:

The following are format-specific syntaxes for TIFF files.
A = imread(...) returns color data that uses the
RGB, CIELAB, ICCLAB, or CMYK color spaces. If the color image uses the CMYK
color space, A is an M-by-N-by-4 array.
[...] = imread(..., idx) reads in one image from a multi-image TIFF file. idx is an integer
value that specifies the order in which the image appears in the file. For example, if idx is 3, imread reads the third image in the file. If you omit this argument, imread reads
the first image in the file.

% For JPEG files, imread does NOT accept a second input.
% That is where your mistake lies.

Subject: error in imread

From: ImageAnalyst

Date: 15 Sep, 2010 21:27:49

Message: 5 of 5

Can you give me some rationale WHY you would want to pass in that
invalid argument? mri.tif MUST have been a 3D image, while I doubt
that cropped.jpg is, in fact I'm nearly 100% sure it is NOT a 3D
image.

Can you simply TRY deleting it like I suggested and giving it a try?
It should be very quick to try.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us