Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ugly, but kinda functional. (please don't upvote)

again, main point here: you want a element-wise multiplication between img and vignette-mat, not a matrix-mult.

Mat img = imread ("lena.jpg");
Mat a,b,c,d,e,f;
double sigma = 80; // vignette 'aperture', the param to play with
a = getGaussianKernel(img.cols,sigma,CV_32F);
b = getGaussianKernel(img.rows,sigma,CV_32F);
c=b*a.t();
double minVal;     
double maxVal;          
cv::minMaxLoc(c, &minVal, &maxVal);
d = c/maxVal;
d.convertTo(d,CV_8U,255);      // hrmff, there should
cvtColor(d,d,COLOR_GRAY2RGB);  // be a way 
d.convertTo(d,CV_32F,1.0/255); // without all this muck
imshow("lla",d);
waitKey(0);
multiply(img,d,e,1,CV_8U);
imshow("lla",e);
waitKey(0);

ugly, but kinda functional. (please don't upvote)

again, main point here: you want a element-wise multiplication between img and vignette-mat, not a matrix-mult.

Mat img = imread ("lena.jpg");
Mat a,b,c,d,e,f;
double sigma = 80; // vignette 'aperture', the param to play with
a = getGaussianKernel(img.cols,sigma,CV_32F);
b = getGaussianKernel(img.rows,sigma,CV_32F);
c=b*a.t();
double minVal;     
double maxVal;          
cv::minMaxLoc(c, &minVal, &maxVal);
d = c/maxVal;
d.convertTo(d,CV_8U,255);      // hrmff, there should
cvtColor(d,d,COLOR_GRAY2RGB);  // be a way 
d.convertTo(d,CV_32F,1.0/255); // without all this muck
imshow("lla",d);
waitKey(0);
multiply(img,d,e,1,CV_8U);
imshow("lla",e);
waitKey(0);

image description