Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiplying an image with a matrix in Matlab

Status
Not open for further replies.

IndiJones

Full Member level 2
Joined
Aug 13, 2001
Messages
132
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
786
multiplying image with mask in matlab

I have a 24 bit RGB image (bmp) that has 1024X1280X3 pixels and is of
uint8 type (matlab shows it when loading the image using 'imread'). I
would like to multiply it with a 3X3 matrix to see how the image
changes. When I do it using the following command:

Image2 = Matrix * Image1;

I get this message:

"??? Error: ==> mtimes
Integers can only be combined with integers of the same class, or
scalar doubles."

Then I converted Image1 into double using:

DoubleImage = imdouble(Image1);

And then tried to do the multiplication once again:

Image2 = Matrix1 * DoubleImage;

This time I got this error:

"??? Error: ==> mtimes
Input arguments must be 2-D."

Could anyone please tell me how am I going to do the multiplication
and then form the output image for viewing.

Thanks in advance!
 

imdouble

I think I need to further clarify the problem. Every pixel of the RGB
planes of the image has to be multiplied by Matrix1. For instance,
the first pixel of each of the three planes R1, G1 & B1 will first be
multiplied by Matrix1, then R2, G2 & B2 will be multiplied and so on.
So it should be a 3X3 matrix multiplied by another 3X1 matrix as
follows:

The first pixels of the new image (say XYZ)

[X1 Y1 Z1] = [m11 m12 m13; m21 m22 m23; m31 m32 m33] * [R1 G1 B1];
.
.
.
[Xn Yn Zn] = [m11 m12 m13; m21 m22 m23; m31 m32 m33] * [Rn Gn Bn];

Finally the output image XYZ will have the pixel values X1,..,Xn for
the X plane, Y1,..,Yn for the Y plane and Z1,..,Zn for the Z plane
and show the final image.
 

If I understand correctly, you try to filter your original picture
with a 3X3 mask ?

If so, use new_pic{m} = conv2(mask,your_pic:),:,m))
where m=1,2,3 as for R,G and B

save each 2-D pic (R,G and B) and combine them to a 3-D array.

Good luck,
P.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top