Ask Your Question

How to operate on each pixel of a with a 3 x 3 matrix?

asked 2012-11-25 21:02:22 -0600

smcamp gravatar image

I want to operate on each bgr pixel of a CvMat with a (3 x 3) Miyazaki matrix (

I have tried various operations but I keep getting various errors.

Any help on what operation/syntax is needed would be greatly appreciated!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-11-26 07:46:12 -0600

AMP gravatar image

I think this code can help you!

Mat x,y,z;
x.convertTo(y,c.type()); //c is your 3x3 matrix
edit flag offensive delete link more



Im using Python and cv2 so I think I have to make a few modifications.

Does "x=Mat(<cv::Vec3b>(i,j));" create a 3 x 1 matrix for each pixel?

Also does this snippet of code assume I am manually iterating over each pixel in the image or is there some built in function I haven't found that will automatically operate on every pixel?



smcamp gravatar imagesmcamp ( 2012-11-26 13:26:18 -0600 )edit

yes,it does create a 3x1 matrix.

you should manually iterate over each pixel by changing i & j in a for loop.

AMP gravatar imageAMP ( 2012-11-27 00:50:34 -0600 )edit

Question Tools


Asked: 2012-11-25 21:02:22 -0600

Seen: 929 times

Last updated: Nov 26 '12