Why ExposureCompensator gives black image as result?

asked 2013-05-02 06:35:16 -0500

Dirhem gravatar image

updated 2013-05-02 07:35:09 -0500

I am trying to use ExposureCompensator class. I am trying to paste a small image to a bigger image but before pasting it i want to balance brightness of two images. When i run the code smallImage will return as a black image.

PS: Also if i use ExposureCompensator::GAIN_BLOCK it gives an error, Integer division by zero.

    int num_images = 2;
int img_idx = 1;

//left and top corner position of small image
int left = 300;
int top = 400;
vector<Point> corners(num_images);
vector<Mat> images_warped(num_images);
vector<Mat> masks_warped(num_images);

images_warped.push_back(bigImage);
images_warped.push_back(smallImage);

corners.push_back(Point(0, 0));
corners.push_back(Point(left, top));

//created two white Mats as masks
Mat bigMask, smallMask;
bigMask.create(bigImage.size(), CV_8U);
bigMask.setTo(Scalar::all(255));

smallMask.create(smallImage.size(), CV_8U);
smallMask.setTo(Scalar::all(255));


masks_warped.push_back(bigMask);
masks_warped.push_back(smallMask);


int expos_comp_type = detail::ExposureCompensator::GAIN;
Ptr<detail::ExposureCompensator> compensator = detail::ExposureCompensator::createDefault(expos_comp_type);
compensator->feed(corners, images_warped, masks_warped);
compensator->apply(img_idx, corners[img_idx], smallImage, smallMask);
edit retag flag offensive close merge delete