OpenCV C++ to calculate vignette effect using gaussian kernel function -
i try convert this reply python c++ , i'm stuck on first call multiply... small input mat 2 dims , 600x400 cols/rows.
mat = getgaussiankernel(small.cols, .3); mat b = getgaussiankernel(small.rows, .3); mat ta; transpose(a, ta); mat c = *new mat(ta.rows, ta.cols, ta.type()); cv::multiply(ta, b, c); mat d; cv::max(c, d); d = c / d; mat e; multiply(small, d, e);
the error message reads:
the operation neither 'array op array' (where arrays have same size , same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op
i'm not familiar either numpy or matplotlib i'm constraint c++ reasons lengthy explain...
if read documentation cv::multiply
see expects first 2 inputs same size , type. because attempting element-wise multiplication.
your gaussian kernel a
defined 600 x 1 (which getgaussiankernel
recommends first input odd) transpose (ta
) going 1 x 600.
the second input, b
defined 400 x 1 (again, should odd size).
obviously these 2 not same size dimensions/size.
instead of using cv::multiply
element-wise multiplication, you'll want use *
operator matrix product want.
mat c = b * ta
which should yield 400 x 600 matrix.
also, switched order of b
, ta
matrix dimensions worked out multiplication.
note have other issues code. you're using cv::max()
compare empty matrix c
. should use cv::minmaxloc
.
the multiplication on last line looks should fine since want apply combination of gaussians image directly input image on pixel-by-pixel or element-by-element basis.
Comments
Post a Comment