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:
How to pass a 2-D image to a function

Subject: How to pass a 2-D image to a function

From: Paul

Date: 31 Jan, 2012 03:52:10

Message: 1 of 4

Hi,

    I am getting the following error while passing a 2-D image to a function

Error using ==> mtimes
MTIMES is not fully supported for integer classes. At least one input must be scalar.

The error is at the following line

G=T*newI;

I checked the dimension, both are 8*8 matrices.

Please help me out in this.Thank you in advance

Subject: How to pass a 2-D image to a function

From: Sadik

Date: 31 Jan, 2012 04:27:09

Message: 2 of 4

Hi Paul,

I don't know exactly what the problem is but at first glance, it says MTIMES is not fully supported for integer class. If I were you, I would try:

G = double(T)*double(newl);

Here, double() casts integer to double.

Best.

Subject: How to pass a 2-D image to a function

From: Sadik

Date: 31 Jan, 2012 04:34:11

Message: 3 of 4

Yes, I reproduced the problem. The matrix multiplication can result in values much larger than 255 [the uint8 max], so even if you use casting to double, you may want to make a decision about how to proceed with values outside the 0-255 range.

Best.

Subject: How to pass a 2-D image to a function

From: Yumnam Kirani

Date: 31 Jan, 2012 11:58:10

Message: 4 of 4

"Sadik " <sadik.hava@gmail.com> wrote in message <jg7r03$7kr$1@newscl01ah.mathworks.com>...
> Yes, I reproduced the problem. The matrix multiplication can result in values much larger than 255 [the uint8 max], so even if you use casting to double, you may want to make a decision about how to proceed with values outside the 0-255 range.
>
> Best.

If you simply want to assign all values greater than 255, you can simply use uint8 function. Otherwise, you need to scale the image after the multiplication to the desired range.

Yumnam Kirani Singh
Tronglaobi Awang Leikai
 

Tags for this Thread

No tags are associated with 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