Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why after fusion my picture is dark

Hello, I use OpenCV 3.4.3 in Java for android I use this script : https://docs.opencv.org/master/d3/db7/tutorial_hdr_imaging.html to make hdr picture.

However My result is to dark and I want to correct it, but I want to keep details out.

There is an exemple : image description

There is My code:

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

textCreating.setVisibility(View.INVISIBLE);

Mat response = new Mat();
CalibrateDebevec calibrate = Photo.createCalibrateDebevec();
Mat matTimes = new Mat(times.size(), 1, CvType.CV_32F);
float[] arrayTimes = new float[(int) (matTimes.total() * matTimes.channels())];
for (int i = 0; i < times.size(); i++) {
       arrayTimes[i] = times.get(i);
}
matTimes.put(0, 0, arrayTimes);
calibrate.process(images, response, matTimes);
Mat hdr = new Mat();
MergeDebevec mergeDebevec = Photo.createMergeDebevec();
mergeDebevec.process(images, hdr, matTimes);

Mat ldr = new Mat();
TonemapDurand tonemap = Photo.createTonemapDurand(4.0f);
tonemap.process(hdr, ldr);

Mat fusion = new Mat();
MergeMertens mergeMertens = Photo.createMergeMertens();
mergeMertens.process(images, fusion);
Core.multiply(fusion, new Scalar(255, 255, 255), fusion);

File dir = new File(Environment.getExternalStorageDirectory() + File.separator + "hdr" + File.separator + "picturesUnfusionned");
if (dir.isDirectory()) {
      String[] children = dir.list();
      for (int i = 0; i < children.length; i++) {
            new File(dir, children[i]).delete();
      }
}

String fileName = Environment.getExternalStorageDirectory() + File.separator + "hdr" + File.separator + "Pictures" + File.separator + "fusion_" + String.valueOf( new File(Environment.getExternalStorageDirectory() + File.separator + "hdr" + File.separator + "Pictures").listFiles().length + 1 ) + ".jpg";
Mat newImage = Mat.zeros(fusion.size(), fusion.type());

double alpha = 1.0; /*< Simple contrast control */
int beta = 10;       /*< Simple brightness control */

fusion.convertTo(newImage, CvType.CV_32F, alpha, beta);

Imgcodecs.imwrite(fileName, newImage);

How can I do to correct the dark pixels ?

Thanks in advance