OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Thu, 03 Dec 2020 05:45:30 -0600Pixel-wise matrix multiplicationhttp://answers.opencv.org/question/238652/pixel-wise-matrix-multiplication/I want to multiply every pixel in an image with a 3x3 matrix, treating every pixel as a 3D-vector of colors.
In mathematical terms the operation would be something like:
**u** = **M** **v**
where **u** is the resulting pixel value, **M** the (3x3) matrix, and **v** the original pixel value.
I have searched the documentation but have not been able to find a way to do this in OpenCV. Does anybody have any suggestions?fadeto404Thu, 03 Dec 2020 05:45:30 -0600http://answers.opencv.org/question/238652/transform 16bit grayscale to RGB with constantshttp://answers.opencv.org/question/131161/transform-16bit-grayscale-to-rgb-with-constants/Hi,
I'm trying to figure out the most appropriate way to do this in OpenCV but I don't have much experience with it
and feel like there should be a better way than just brute force.
I'm staring with a 16bit grayscale image (CV_16UC1) and I want to produce a RGB image (CV_8UC3)
But I don't want to use a simple conversion like o1.convertTo(o2, CV_8UC3, 1/255.0);
Rather, I have 3 constant scaling factors (each between 0 and 1 corresponding to each of R,G and B)
Each resulting RGB pixel value should be the original 16bit grayscale pixel value multiplied by one of the three constants and then scaled down to a value between 0-255.
Thoughts?
Thanks!
pmh4514Fri, 03 Mar 2017 07:53:55 -0600http://answers.opencv.org/question/131161/Matrix multiplicationhttp://answers.opencv.org/question/13399/matrix-multiplication/Hi,
I have to reimplement some methods from opencv for real time operations. But some of these are using gemm for "simple" matrix multiplication.
Looking in the sources I can't find the operator* for cv::Mat.
When I write something like C = A*B (with A, B, C cv::Mat). Does it call `gemm(A, B, 1.0, Mat(), 0.0, C);` ?RogeeeerWed, 15 May 2013 08:04:23 -0500http://answers.opencv.org/question/13399/Product of two matriceshttp://answers.opencv.org/question/10770/product-of-two-matrices/Hi,
I use OpenCV 2.4.4 with Java. I have problem with simple multiplication of two matrices. I define it in my code in following way:
>**Mat m1 = Mat.ones(3, 3, CvType.CV_16SC1);**
>**Mat m2 = Mat.ones(3, 3, CvType.CV_16SC1);**
In case if I multiply:
> Mat m3 = m1 * m2;
I achieved error that operator * is undefined.
I know that OpenCv for Java provides function mul and i can use it:
> **Mat m3 = m1.mul(m2);**
but in this way I receive only product of [elementwise](http://www.glue.umd.edu/afs/glue.umd.edu/system/info/olh/Numerical/Matlab_Matrix_Manipulation_Software/Matrix_Vector_Operations/elementwise "elementwise") multiplication what is not my objective.
Is there some replacement function which allow me to multiply two matrices like * operator?
Thanks in advance :)
DominikThu, 04 Apr 2013 17:04:56 -0500http://answers.opencv.org/question/10770/