Asked by Sabarinathan Vadivelu
on 10 Sep 2012

Considering an image I of any size. A mask of size 1X10. How to multiply those two?

Answer by Titus Edelhofer
on 10 Sep 2012

Accepted answer

Hi,

the error indicates what's wrong: your image and your mask have different types (probably your image is e.g. uint8 and your mask is double). If you need your mask to have non integer values (e.g. 2.345), convert your image to double:

dblImage = double(yourImage);

Otherwise you might try to convert your mask to the same integer type as your image (by using uint8, ...).

Titus

Show 1 older comment

Sabarinathan Vadivelu
on 10 Sep 2012

This is my code. deg0 is 1X10 mask. threshImage is the input Image.

for i=1:10 deg0(i) = 0.25; end deg0=cast(deg0,'uint8'); [rows columns] = size(threshImage); for j = 1 : columns for i= 1 : 10 : rows filtImage0(i,j) = threshImage(i,j).*deg0; end end

Titus Edelhofer
on 10 Sep 2012

Hi,

if you do it by loop, you need to index deg0 as well:

filtImage0(i,j) = threshImage(i,j).*deg0(i);

or

filtImage0(i,j) = threshImage(i,j).*deg0(j);

Titus

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 3 Comments

## Sivakumaran Chandrasekaran (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/47733#comment_98461

a.*b... Most probably it should work

## Sabarinathan Vadivelu (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/47733#comment_98463

I'm getting error

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/47733#comment_98481

You cannot multiply a [MxNx3] array directly by a [1x10] vector. It is not clear what kind of output you expect for such a calculation.