Why ExposureCompensator gives black image as result?

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

Dirhem gravatar image

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

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);


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);

smallMask.create(smallImage.size(), CV_8U);


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