As @berak commented, you are not using cv::Size
correctly, whose first parameter is width
, and second height
(not the other way around).
Change
resize(im2, image, Size(input.rows, input.cols));
to
resize(im2, image, Size(input.cols, input.rows));
Update: You further need to address image
that is passed in to function blending_overlay
. It has only one channel, but you're trying to access other channels from it:
float target = (float)img1.at<uchar>(i, 3*j+c)/255.0 ; // img1 = image here