From 6ee1f6f66e3c9a8dae9c44f2abcede24134169ba Mon Sep 17 00:00:00 2001 From: Alexandre Benoit Date: Thu, 15 Dec 2011 22:45:28 +0000 Subject: [PATCH] removing some mistakes --- ...hDynamicRange_Retina_toneMapping_video.cpp | 126 +++++++++++------- 1 file changed, 81 insertions(+), 45 deletions(-) diff --git a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp index 5f57353ba..85b2dc6fb 100644 --- a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp +++ b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp @@ -1,10 +1,13 @@ //============================================================================ -// Name : HighDynamicRange_RetinaCompression.cpp +// Name : OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp // Author : Alexandre Benoit (benoit.alexandre.vision@gmail.com) -// Version : 0.1 +// Version : 0.2 // Copyright : Alexandre Benoit, LISTIC Lab, december 2011 -// Description : HighDynamicRange compression (tone mapping) with the help of the Gipsa/Listic's retina in C++, Ansi-style +// Description : HighDynamicRange compression (tone mapping) for image sequences with the help of the Gipsa/Listic's retina in C++, Ansi-style +// Known issues: the input OpenEXR sequences can have bad computed pixels that should be removed +// => a simple method consists of cutting histogram edges (a slider for this on the UI is provided) +// => however, in image sequences, this histogramm cut must be done in an elegant way from frame to frame... still not done... //============================================================================ #include @@ -22,8 +25,10 @@ void help(std::string errorMessage) std::cout<<"\t[start frame] : the starting frame tat should be considered"< to process images from memorial020d.exr to memorial045d.exr"< image size (h,w,channels) = "< pixel coding (nbchannel, bytes per channel) = "< scale, offset = "<(i)<<", "<(i)<(i)(i)<1-histogramClippingLimit) + if ( denseProb.at(i)<1.f-histogramClippingLimit) histUpperLimit=i; } // deduce min and max admitted gray levels - float minInputValue = (float)histLowerLimit/histSize*255; - float maxInputValue = (float)histUpperLimit/histSize*255; + float minInputValue = (float)histLowerLimit/histSize*255.f; + float maxInputValue = (float)histUpperLimit/histSize*255.f; std::cout<<"=> Histogram limits " - <<"\n\t"< normalizedHist value = "<(histLowerLimit)<<" => input gray level = "< normalizedHist value = "<(histUpperLimit)<<" => input gray level = "< normalizedHist value = "<(histLowerLimit)<<" => input gray level = "< normalizedHist value = "<(histUpperLimit)<<" => input gray level = "< Input Hist clipping values (max,min) = "< actually using a little less in order to let some more flexibility in range evolves... + */ + double maxInput, minInput; + minMaxLoc(inputImage, &minInput, &maxInput); + std::cout<<"FIRST IMAGE pixels values range (max,min) : "<8bits linear rescaling ", currentFrame); + imshow("EXR image original image, 16bits=>8bits linear rescaling ", imageInputRescaled); cv::Mat gammaTransformedImage; - cv::pow(currentFrame, 1./5, gammaTransformedImage); // apply gamma curve: img = img ** (1./5) + cv::pow(imageInputRescaled, 1./5, gammaTransformedImage); // apply gamma curve: img = img ** (1./5) imshow(powerTransformedInput, gammaTransformedImage); // run retina filter retina->run(imageInputRescaled); // Retrieve and display retina output retina->getParvo(retinaOutput_parvo); - cv::imshow(retinaInputCorrected, imageInputRescaled/255.0); + cv::imshow(retinaInputCorrected, imageInputRescaled/255.f); cv::imshow(RetinaParvoWindow, retinaOutput_parvo); cv::waitKey(4); // jump to next frame