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

New to MATLAB?

I have these two codes. Can someone help me determine whats wrong with them.

Asked by Andrew

Andrew (view profile)

on 8 Jan 2013

For the "jpegcomp" code, i get an error message telling me to "% load file of variables containing a gray image matrix" even when i load a greyscale lenna image.

for the "didi.m" code, i get an error on ine 12...

I am using matlab R2007b version. Please look at my codes and advise me on what to do.

jpegcomp code: https://www.dropbox.com/s/lpffodrrrwypxjl/jpegcomp.m

didi.m code: https://www.dropbox.com/s/nyj3ygks2d0t2mx/didi.m

thank you very much

3 Comments

Walter Roberson

Walter Roberson (view profile)

on 8 Jan 2013

What error do you get on line 12? Is it complaining that dct() is unknown? Do you have the Signal Processing Toolbox installed? (Image Processing Toolbox has dct2(), the 2D equivalent.)

Andrew

Andrew (view profile)

on 8 Jan 2013

this is the comment i get when i run the code..

"(An input argument of type 'double') method 'dct' function, or undefined." Error ==> didi at 12 rowdct = dct(double(o(i,:,k)));

Walter Roberson

Walter Roberson (view profile)

on 8 Jan 2013

So it is complaining that dct is unknown. Do you have the Signal Processing Toolbox installed?

Andrew

Andrew (view profile)

1 Answer

Answer by Image Analyst

Image Analyst (view profile)

on 8 Jan 2013

o is a bad name for a variable - looks too much like a zero. Anyway, put these lines in and tell me what's in the command window:

whos o
[rows, columns, numberOfColorChannels] = size(o)  % No semicolon!

2 Comments

Andrew

Andrew (view profile)

on 8 Jan 2013

This is what i get when i input your statement into the command window

>> whos o [rows, columns, numberOfColorChannels] = size(o) Name Size Bytes Class Attributes

o         275x183x3            150975  uint8              

rows =

   275

columns =

   183

numberOfColorChannels =

     3
Walter Roberson

Walter Roberson (view profile)

on 8 Jan 2013

That is an RGB image, not a grayscale image as you earlier claimed. It is possible that the R, G, and B planes are all the same; if so then

oR = o(:,:,1);

and work on that instead of on "o".

Image Analyst

Image Analyst (view profile)

Contact us