exposure compensation module not giving giving desired output

asked 2017-09-28 09:22:48 -0500

Tawsif gravatar image

Im am following the stitching pipeline of opencv to compensate exposure errors followed by a blending operation. however, the input images resembles exactly the output as if no processing has been done. When I checked the exposure_compensation.cpp file in opencv, the gains obtained are indeed very very low. For example, for the gain compensation function, what I get is [a,b] = [0.9434352570028618; 1.050340462492959].

Here is the code: /// input images ////

imModel371 = imread("../data/stitching/PS_Pyr2_371.png"); imModel377 = imread("../data/stitching/ImgdRGB.png");

/// Compute Masks ///////////////////

int num_images = 2;
vector<cv::Point> corners(2);
vector<UMat> images_warped(num_images);
vector<Size> sizes(num_images);
vector<UMat> mask_warp(num_images);

cv::Mat I[num_images];
cv::Mat mask[num_images];
 I[0] = imModel371.clone();
 I[1] = imModel377.clone();
Mat mask1(I[0].size(), CV_8U);

// Mask defines visible region of 1st image mask1(Rect(200, 0, (mask1.cols * .75), (mask1.rows) )).setTo(255); mask[0] = (mask1 & cvMask8U)255; mask[1] = (mask1 & cvMask8U)255; I[0].copyTo(images_warped[0]); I[1].copyTo(images_warped[1]);

  mask[0].copyTo(mask_warp[0]);
  mask[1].copyTo(mask_warp[1]);

  cv::namedWindow("Blending Mask",WINDOW_NORMAL);
  cv::imshow("Blending Mask", mask_warp[0]);
  cv::waitKey(0);

///Prepare Exposure Compensator ///////////////////

int expos_comp_type = ExposureCompensator::GAIN; Ptr<exposurecompensator> compensator = ExposureCompensator::createDefault(expos_comp_type);

  for (int img_idx = 0; img_idx < num_images; ++img_idx)
      corners[img_idx]= cv::Point(0,0);


  cout<<"feed compensator"<<endl;

  compensator->feed(corners, images_warped, mask_warp);
  cout<<"apply compensator"<<endl;

  for (int img_idx = 0; img_idx < 2; ++img_idx)
     {
     compensator->apply(img_idx, corners[img_idx], images_warped[img_idx], mask_warp[img_idx]);

  }
  cv::namedWindow("Exposure Compensation 1",WINDOW_NORMAL);
  cv::imshow("Exposure Compensation 1", images_warped[0]);
  cv::namedWindow("Exposure Compensation 2",WINDOW_NORMAL);
  cv::imshow("Exposure Compensation 2", images_warped[1]);
  cv::waitKey(0);

/// Prepare for blending /////////////////// ... .. ... ...

edit retag flag offensive close merge delete