mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
Docs updated, added InputArray, fixes for makePtr,...
This commit is contained in:
parent
f99be6bda6
commit
c9ace38897
@ -39,4 +39,3 @@
|
||||
#7 & #8 & #9
|
||||
\end{bmatrix}
|
||||
}
|
||||
|
||||
|
@ -1,418 +0,0 @@
|
||||
.. _Retina_Model:
|
||||
|
||||
Discovering the human retina and its use for image processing
|
||||
*************************************************************
|
||||
|
||||
Goal
|
||||
=====
|
||||
|
||||
I present here a model of human retina that shows some interesting properties for image preprocessing and enhancement.
|
||||
In this tutorial you will learn how to:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ discover the main two channels outing from your retina
|
||||
|
||||
+ see the basics to use the retina model
|
||||
|
||||
+ discover some parameters tweaks
|
||||
|
||||
|
||||
General overview
|
||||
================
|
||||
|
||||
The proposed model originates from Jeanny Herault's research [herault2010]_ at `Gipsa <http://www.gipsa-lab.inpg.fr>`_. It is involved in image processing applications with `Listic <http://www.listic.univ-savoie.fr>`_ (code maintainer and user) lab. This is not a complete model but it already present interesting properties that can be involved for enhanced image processing experience. The model allows the following human retina properties to be used :
|
||||
|
||||
* spectral whitening that has 3 important effects: high spatio-temporal frequency signals canceling (noise), mid-frequencies details enhancement and low frequencies luminance energy reduction. This *all in one* property directly allows visual signals cleaning of classical undesired distortions introduced by image sensors and input luminance range.
|
||||
|
||||
* local logarithmic luminance compression allows details to be enhanced even in low light conditions.
|
||||
|
||||
* decorrelation of the details information (Parvocellular output channel) and transient information (events, motion made available at the Magnocellular output channel).
|
||||
|
||||
The first two points are illustrated below :
|
||||
|
||||
In the figure below, the OpenEXR image sample *CrissyField.exr*, a High Dynamic Range image is shown. In order to make it visible on this web-page, the original input image is linearly rescaled to the classical image luminance range [0-255] and is converted to 8bit/channel format. Such strong conversion hides many details because of too strong local contrasts. Furthermore, noise energy is also strong and pollutes visual information.
|
||||
|
||||
.. image:: images/retina_TreeHdr_small.jpg
|
||||
:alt: A High dynamic range image linearly rescaled within range [0-255].
|
||||
:align: center
|
||||
|
||||
In the following image, applying the ideas proposed in [benoit2010]_, as your retina does, local luminance adaptation, spatial noise removal and spectral whitening work together and transmit accurate information on lower range 8bit data channels. On this picture, noise in significantly removed, local details hidden by strong luminance contrasts are enhanced. Output image keeps its naturalness and visual content is enhanced. Color processing is based on the color multiplexing/demultiplexing method proposed in [chaix2007]_.
|
||||
|
||||
.. image:: images/retina_TreeHdr_retina.jpg
|
||||
:alt: A High dynamic range image compressed within range [0-255] using the retina.
|
||||
:align: center
|
||||
|
||||
|
||||
*Note :* image sample can be downloaded from the `OpenEXR website <http://www.openexr.com>`_. Regarding this demonstration, before retina processing, input image has been linearly rescaled within 0-255 keeping its channels float format. 5% of its histogram ends has been cut (mostly removes wrong HDR pixels). Check out the sample *opencv/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp* for similar processing. The following demonstration will only consider classical 8bit/channel images.
|
||||
|
||||
The retina model output channels
|
||||
================================
|
||||
|
||||
The retina model presents two outputs that benefit from the above cited behaviors.
|
||||
|
||||
* The first one is called the Parvocellular channel. It is mainly active in the foveal retina area (high resolution central vision with color sensitive photo-receptors), its aim is to provide accurate color vision for visual details remaining static on the retina. On the other hand objects moving on the retina projection are blurred.
|
||||
|
||||
* The second well known channel is the Magnocellular channel. It is mainly active in the retina peripheral vision and send signals related to change events (motion, transient events, etc.). These outing signals also help visual system to focus/center retina on 'transient'/moving areas for more detailed analysis thus improving visual scene context and object classification.
|
||||
|
||||
**NOTE :** regarding the proposed model, contrary to the real retina, we apply these two channels on the entire input images using the same resolution. This allows enhanced visual details and motion information to be extracted on all the considered images... but remember, that these two channels are complementary. For example, if Magnocellular channel gives strong energy in an area, then, the Parvocellular channel is certainly blurred there since there is a transient event.
|
||||
|
||||
As an illustration, we apply in the following the retina model on a webcam video stream of a dark visual scene. In this visual scene, captured in an amphitheater of the university, some students are moving while talking to the teacher.
|
||||
|
||||
In this video sequence, because of the dark ambiance, signal to noise ratio is low and color artifacts are present on visual features edges because of the low quality image capture tool-chain.
|
||||
|
||||
.. image:: images/studentsSample_input.jpg
|
||||
:alt: an input video stream extract sample
|
||||
:align: center
|
||||
|
||||
Below is shown the retina foveal vision applied on the entire image. In the used retina configuration, global luminance is preserved and local contrasts are enhanced. Also, signal to noise ratio is improved : since high frequency spatio-temporal noise is reduced, enhanced details are not corrupted by any enhanced noise.
|
||||
|
||||
.. image:: images/studentsSample_parvo.jpg
|
||||
:alt: the retina Parvocellular output. Enhanced details, luminance adaptation and noise removal. A processing tool for image analysis.
|
||||
:align: center
|
||||
|
||||
Below is the output of the Magnocellular output of the retina model. Its signals are strong where transient events occur. Here, a student is moving at the bottom of the image thus generating high energy. The remaining of the image is static however, it is corrupted by a strong noise. Here, the retina filters out most of the noise thus generating low false motion area 'alarms'. This channel can be used as a transient/moving areas detector : it would provide relevant information for a low cost segmentation tool that would highlight areas in which an event is occurring.
|
||||
|
||||
.. image:: images/studentsSample_magno.jpg
|
||||
:alt: the retina Magnocellular output. Enhanced transient signals (motion, etc.). A preprocessing tool for event detection.
|
||||
:align: center
|
||||
|
||||
Retina use case
|
||||
===============
|
||||
|
||||
This model can be used basically for spatio-temporal video effects but also in the aim of :
|
||||
|
||||
* performing texture analysis with enhanced signal to noise ratio and enhanced details robust against input images luminance ranges (check out the Parvocellular retina channel output)
|
||||
|
||||
* performing motion analysis also taking benefit of the previously cited properties.
|
||||
|
||||
Literature
|
||||
==========
|
||||
For more information, refer to the following papers :
|
||||
|
||||
.. [benoit2010] Benoit A., Caplier A., Durette B., Herault, J., "Using Human Visual System Modeling For Bio-Inspired Low Level Image Processing", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773. DOI <http://dx.doi.org/10.1016/j.cviu.2010.01.011>
|
||||
|
||||
* Please have a look at the reference work of Jeanny Herault that you can read in his book :
|
||||
|
||||
.. [herault2010] Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.
|
||||
|
||||
This retina filter code includes the research contributions of phd/research collegues from which code has been redrawn by the author :
|
||||
|
||||
* take a look at the *retinacolor.hpp* module to discover Brice Chaix de Lavarene phD color mosaicing/demosaicing and his reference paper:
|
||||
|
||||
.. [chaix2007] B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007
|
||||
|
||||
* take a look at *imagelogpolprojection.hpp* to discover retina spatial log sampling which originates from Barthelemy Durette phd with Jeanny Herault. A Retina / V1 cortex projection is also proposed and originates from Jeanny's discussions. More informations in the above cited Jeanny Heraults's book.
|
||||
|
||||
Code tutorial
|
||||
=============
|
||||
|
||||
Please refer to the original tutorial source code in file *opencv_folder/samples/cpp/tutorial_code/bioinspired/retina_tutorial.cpp*.
|
||||
|
||||
**Note :** do not forget that the retina model is included in the following namespace : *cv::bioinspired*.
|
||||
|
||||
To compile it, assuming OpenCV is correctly installed, use the following command. It requires the opencv_core *(cv::Mat and friends objects management)*, opencv_highgui *(display and image/video read)* and opencv_bioinspired *(Retina description)* libraries to compile.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// compile
|
||||
gcc retina_tutorial.cpp -o Retina_tuto -lopencv_core -lopencv_highgui -lopencv_bioinspired
|
||||
|
||||
// Run commands : add 'log' as a last parameter to apply a spatial log sampling (simulates retina sampling)
|
||||
// run on webcam
|
||||
./Retina_tuto -video
|
||||
// run on video file
|
||||
./Retina_tuto -video myVideo.avi
|
||||
// run on an image
|
||||
./Retina_tuto -image myPicture.jpg
|
||||
// run on an image with log sampling
|
||||
./Retina_tuto -image myPicture.jpg log
|
||||
|
||||
Here is a code explanation :
|
||||
|
||||
Retina definition is present in the bioinspired package and a simple include allows to use it. You can rather use the specific header : *opencv2/bioinspired.hpp* if you prefer but then include the other required openv modules : *opencv2/core.hpp* and *opencv2/highgui.hpp*
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
Provide user some hints to run the program with a help function
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// the help procedure
|
||||
static void help(std::string errorMessage)
|
||||
{
|
||||
std::cout<<"Program init error : "<<errorMessage<<std::endl;
|
||||
std::cout<<"\nProgram call procedure : retinaDemo [processing mode] [Optional : media target] [Optional LAST parameter: \"log\" to activate retina log sampling]"<<std::endl;
|
||||
std::cout<<"\t[processing mode] :"<<std::endl;
|
||||
std::cout<<"\t -image : for still image processing"<<std::endl;
|
||||
std::cout<<"\t -video : for video stream processing"<<std::endl;
|
||||
std::cout<<"\t[Optional : media target] :"<<std::endl;
|
||||
std::cout<<"\t if processing an image or video file, then, specify the path and filename of the target to process"<<std::endl;
|
||||
std::cout<<"\t leave empty if processing video stream coming from a connected video device"<<std::endl;
|
||||
std::cout<<"\t[Optional : activate retina log sampling] : an optional last parameter can be specified for retina spatial log sampling"<<std::endl;
|
||||
std::cout<<"\t set \"log\" without quotes to activate this sampling, output frame size will be divided by 4"<<std::endl;
|
||||
std::cout<<"\nExamples:"<<std::endl;
|
||||
std::cout<<"\t-Image processing : ./retinaDemo -image lena.jpg"<<std::endl;
|
||||
std::cout<<"\t-Image processing with log sampling : ./retinaDemo -image lena.jpg log"<<std::endl;
|
||||
std::cout<<"\t-Video processing : ./retinaDemo -video myMovie.mp4"<<std::endl;
|
||||
std::cout<<"\t-Live video processing : ./retinaDemo -video"<<std::endl;
|
||||
std::cout<<"\nPlease start again with new parameters"<<std::endl;
|
||||
std::cout<<"****************************************************"<<std::endl;
|
||||
std::cout<<" NOTE : this program generates the default retina parameters file 'RetinaDefaultParameters.xml'"<<std::endl;
|
||||
std::cout<<" => you can use this to fine tune parameters and load them if you save to file 'RetinaSpecificParameters.xml'"<<std::endl;
|
||||
}
|
||||
|
||||
Then, start the main program and first declare a *cv::Mat* matrix in which input images will be loaded. Also allocate a *cv::VideoCapture* object ready to load video streams (if necessary)
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// declare the retina input buffer... that will be fed differently in regard of the input media
|
||||
cv::Mat inputFrame;
|
||||
cv::VideoCapture videoCapture; // in case a video media is used, its manager is declared here
|
||||
|
||||
|
||||
In the main program, before processing, first check input command parameters. Here it loads a first input image coming from a single loaded image (if user chose command *-image*) or from a video stream (if user chose command *-video*). Also, if the user added *log* command at the end of its program call, the spatial logarithmic image sampling performed by the retina is taken into account by the Boolean flag *useLogSampling*.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// welcome message
|
||||
std::cout<<"****************************************************"<<std::endl;
|
||||
std::cout<<"* Retina demonstration : demonstrates the use of is a wrapper class of the Gipsa/Listic Labs retina model."<<std::endl;
|
||||
std::cout<<"* This demo will try to load the file 'RetinaSpecificParameters.xml' (if exists).\nTo create it, copy the autogenerated template 'RetinaDefaultParameters.xml'.\nThen twaek it with your own retina parameters."<<std::endl;
|
||||
// basic input arguments checking
|
||||
if (argc<2)
|
||||
{
|
||||
help("bad number of parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool useLogSampling = !strcmp(argv[argc-1], "log"); // check if user wants retina log sampling processing
|
||||
|
||||
std::string inputMediaType=argv[1];
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// checking input media type (still image, video file, live video acquisition)
|
||||
if (!strcmp(inputMediaType.c_str(), "-image") && argc >= 3)
|
||||
{
|
||||
std::cout<<"RetinaDemo: processing image "<<argv[2]<<std::endl;
|
||||
// image processing case
|
||||
inputFrame = cv::imread(std::string(argv[2]), 1); // load image in RGB mode
|
||||
}else
|
||||
if (!strcmp(inputMediaType.c_str(), "-video"))
|
||||
{
|
||||
if (argc == 2 || (argc == 3 && useLogSampling)) // attempt to grab images from a video capture device
|
||||
{
|
||||
videoCapture.open(0);
|
||||
}else// attempt to grab images from a video filestream
|
||||
{
|
||||
std::cout<<"RetinaDemo: processing video stream "<<argv[2]<<std::endl;
|
||||
videoCapture.open(argv[2]);
|
||||
}
|
||||
|
||||
// grab a first frame to check if everything is ok
|
||||
videoCapture>>inputFrame;
|
||||
}else
|
||||
{
|
||||
// bad command parameter
|
||||
help("bad command parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Once all input parameters are processed, a first image should have been loaded, if not, display error and stop program :
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
if (inputFrame.empty())
|
||||
{
|
||||
help("Input media could not be loaded, aborting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Now, everything is ready to run the retina model. I propose here to allocate a retina instance and to manage the eventual log sampling option. The Retina constructor expects at least a cv::Size object that shows the input data size that will have to be managed. One can activate other options such as color and its related color multiplexing strategy (here Bayer multiplexing is chosen using *enum cv::bioinspired::RETINA_COLOR_BAYER*). If using log sampling, the image reduction factor (smaller output images) and log sampling strengh can be adjusted.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// pointer to a retina object
|
||||
cv::Ptr<Retina> myRetina;
|
||||
|
||||
// if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision)
|
||||
if (useLogSampling)
|
||||
{
|
||||
myRetina = cv::bioinspired::createRetina(inputFrame.size(), true, cv::bioinspired::RETINA_COLOR_BAYER, true, 2.0, 10.0);
|
||||
}
|
||||
else// -> else allocate "classical" retina :
|
||||
myRetina = cv::bioinspired::createRetina(inputFrame.size());
|
||||
|
||||
Once done, the proposed code writes a default xml file that contains the default parameters of the retina. This is useful to make your own config using this template. Here generated template xml file is called *RetinaDefaultParameters.xml*.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// save default retina parameters file in order to let you see this and maybe modify it and reload using method "setup"
|
||||
myRetina->write("RetinaDefaultParameters.xml");
|
||||
|
||||
In the following line, the retina attempts to load another xml file called *RetinaSpecificParameters.xml*. If you created it and introduced your own setup, it will be loaded, in the other case, default retina parameters are used.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// load parameters if file exists
|
||||
myRetina->setup("RetinaSpecificParameters.xml");
|
||||
|
||||
It is not required here but just to show it is possible, you can reset the retina buffers to zero to force it to forget past events.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// reset all retina buffers (imagine you close your eyes for a long time)
|
||||
myRetina->clearBuffers();
|
||||
|
||||
Now, it is time to run the retina ! First create some output buffers ready to receive the two retina channels outputs
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// declare retina output buffers
|
||||
cv::Mat retinaOutput_parvo;
|
||||
cv::Mat retinaOutput_magno;
|
||||
|
||||
Then, run retina in a loop, load new frames from video sequence if necessary and get retina outputs back to dedicated buffers.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// processing loop with no stop condition
|
||||
while(true)
|
||||
{
|
||||
// if using video stream, then, grabbing a new frame, else, input remains the same
|
||||
if (videoCapture.isOpened())
|
||||
videoCapture>>inputFrame;
|
||||
|
||||
// run retina filter on the loaded input frame
|
||||
myRetina->run(inputFrame);
|
||||
// Retrieve and display retina output
|
||||
myRetina->getParvo(retinaOutput_parvo);
|
||||
myRetina->getMagno(retinaOutput_magno);
|
||||
cv::imshow("retina input", inputFrame);
|
||||
cv::imshow("Retina Parvo", retinaOutput_parvo);
|
||||
cv::imshow("Retina Magno", retinaOutput_magno);
|
||||
cv::waitKey(10);
|
||||
}
|
||||
|
||||
That's done ! But if you want to secure the system, take care and manage Exceptions. The retina can throw some when it sees irrelevant data (no input frame, wrong setup, etc.).
|
||||
Then, i recommend to surround all the retina code by a try/catch system like this :
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
try{
|
||||
// pointer to a retina object
|
||||
cv::Ptr<cv::Retina> myRetina;
|
||||
[---]
|
||||
// processing loop with no stop condition
|
||||
while(true)
|
||||
{
|
||||
[---]
|
||||
}
|
||||
|
||||
}catch(cv::Exception e)
|
||||
{
|
||||
std::cerr<<"Error using Retina : "<<e.what()<<std::endl;
|
||||
}
|
||||
|
||||
Retina parameters, what to do ?
|
||||
===============================
|
||||
|
||||
First, it is recommended to read the reference paper :
|
||||
|
||||
* Benoit A., Caplier A., Durette B., Herault, J., *"Using Human Visual System Modeling For Bio-Inspired Low Level Image Processing"*, Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773. DOI <http://dx.doi.org/10.1016/j.cviu.2010.01.011>
|
||||
|
||||
Once done open the configuration file *RetinaDefaultParameters.xml* generated by the demo and let's have a look at it.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<opencv_storage>
|
||||
<OPLandIPLparvo>
|
||||
<colorMode>1</colorMode>
|
||||
<normaliseOutput>1</normaliseOutput>
|
||||
<photoreceptorsLocalAdaptationSensitivity>7.5e-01</photoreceptorsLocalAdaptationSensitivity>
|
||||
<photoreceptorsTemporalConstant>9.0e-01</photoreceptorsTemporalConstant>
|
||||
<photoreceptorsSpatialConstant>5.7e-01</photoreceptorsSpatialConstant>
|
||||
<horizontalCellsGain>0.01</horizontalCellsGain>
|
||||
<hcellsTemporalConstant>0.5</hcellsTemporalConstant>
|
||||
<hcellsSpatialConstant>7.</hcellsSpatialConstant>
|
||||
<ganglionCellsSensitivity>7.5e-01</ganglionCellsSensitivity></OPLandIPLparvo>
|
||||
<IPLmagno>
|
||||
<normaliseOutput>1</normaliseOutput>
|
||||
<parasolCells_beta>0.</parasolCells_beta>
|
||||
<parasolCells_tau>0.</parasolCells_tau>
|
||||
<parasolCells_k>7.</parasolCells_k>
|
||||
<amacrinCellsTemporalCutFrequency>2.0e+00</amacrinCellsTemporalCutFrequency>
|
||||
<V0CompressionParameter>9.5e-01</V0CompressionParameter>
|
||||
<localAdaptintegration_tau>0.</localAdaptintegration_tau>
|
||||
<localAdaptintegration_k>7.</localAdaptintegration_k></IPLmagno>
|
||||
</opencv_storage>
|
||||
|
||||
Here are some hints but actually, the best parameter setup depends more on what you want to do with the retina rather than the images input that you give to retina. Apart from the more specific case of High Dynamic Range images (HDR) that require more specific setup for specific luminance compression objective, the retina behaviors should be rather stable from content to content. Note that OpenCV is able to manage such HDR format thanks to the OpenEXR images compatibility.
|
||||
|
||||
Then, if the application target requires details enhancement prior to specific image processing, you need to know if mean luminance information is required or not. If not, the the retina can cancel or significantly reduce its energy thus giving more visibility to higher spatial frequency details.
|
||||
|
||||
|
||||
Basic parameters
|
||||
----------------
|
||||
|
||||
The most simple parameters are the following :
|
||||
|
||||
* **colorMode** : let the retina process color information (if 1) or gray scale images (if 0). In this last case, only the first channel of the input will be processed.
|
||||
|
||||
* **normaliseOutput** : each channel has this parameter, if value is 1, then the considered channel output is rescaled between 0 and 255. Take care in this case at the Magnocellular output level (motion/transient channel detection). Residual noise will also be rescaled !
|
||||
|
||||
**Note :** using color requires color channels multiplexing/demultipexing which requires more processing. You can expect much faster processing using gray levels : it would require around 30 product per pixel for all the retina processes and it has recently been parallelized for multicore architectures.
|
||||
|
||||
Photo-receptors parameters
|
||||
--------------------------
|
||||
|
||||
The following parameters act on the entry point of the retina - photo-receptors - and impact all the following processes. These sensors are low pass spatio-temporal filters that smooth temporal and spatial data and also adjust there sensitivity to local luminance thus improving details extraction and high frequency noise canceling.
|
||||
|
||||
* **photoreceptorsLocalAdaptationSensitivity** between 0 and 1. Values close to 1 allow high luminance log compression effect at the photo-receptors level. Values closer to 0 give a more linear sensitivity. Increased alone, it can burn the *Parvo (details channel)* output image. If adjusted in collaboration with **ganglionCellsSensitivity** images can be very contrasted whatever the local luminance there is... at the price of a naturalness decrease.
|
||||
|
||||
* **photoreceptorsTemporalConstant** this setups the temporal constant of the low pass filter effect at the entry of the retina. High value lead to strong temporal smoothing effect : moving objects are blurred and can disappear while static object are favored. But when starting the retina processing, stable state is reached lately.
|
||||
|
||||
* **photoreceptorsSpatialConstant** specifies the spatial constant related to photo-receptors low pass filter effect. This parameters specify the minimum allowed spatial signal period allowed in the following. Typically, this filter should cut high frequency noise. Then a 0 value doesn't cut anything noise while higher values start to cut high spatial frequencies and more and more lower frequencies... Then, do not go to high if you wanna see some details of the input images ! A good compromise for color images is 0.53 since this won't affect too much the color spectrum. Higher values would lead to gray and blurred output images.
|
||||
|
||||
Horizontal cells parameters
|
||||
---------------------------
|
||||
|
||||
This parameter set tunes the neural network connected to the photo-receptors, the horizontal cells. It modulates photo-receptors sensitivity and completes the processing for final spectral whitening (part of the spatial band pass effect thus favoring visual details enhancement).
|
||||
|
||||
* **horizontalCellsGain** here is a critical parameter ! If you are not interested by the mean luminance and focus on details enhancement, then, set to zero. But if you want to keep some environment luminance data, let some low spatial frequencies pass into the system and set a higher value (<1).
|
||||
|
||||
* **hcellsTemporalConstant** similar to photo-receptors, this acts on the temporal constant of a low pass temporal filter that smooths input data. Here, a high value generates a high retina after effect while a lower value makes the retina more reactive. This value should be lower than **photoreceptorsTemporalConstant** to limit strong retina after effects.
|
||||
|
||||
* **hcellsSpatialConstant** is the spatial constant of the low pass filter of these cells filter. It specifies the lowest spatial frequency allowed in the following. Visually, a high value leads to very low spatial frequencies processing and leads to salient halo effects. Lower values reduce this effect but the limit is : do not go lower than the value of **photoreceptorsSpatialConstant**. Those 2 parameters actually specify the spatial band-pass of the retina.
|
||||
|
||||
**NOTE** after the processing managed by the previous parameters, input data is cleaned from noise and luminance in already partly enhanced. The following parameters act on the last processing stages of the two outing retina signals.
|
||||
|
||||
Parvo (details channel) dedicated parameter
|
||||
-------------------------------------------
|
||||
|
||||
* **ganglionCellsSensitivity** specifies the strength of the final local adaptation occurring at the output of this details dedicated channel. Parameter values remain between 0 and 1. Low value tend to give a linear response while higher values enforces the remaining low contrasted areas.
|
||||
|
||||
**Note :** this parameter can correct eventual burned images by favoring low energetic details of the visual scene, even in bright areas.
|
||||
|
||||
IPL Magno (motion/transient channel) parameters
|
||||
-----------------------------------------------
|
||||
|
||||
Once image information is cleaned, this channel acts as a high pass temporal filter that only selects signals related to transient signals (events, motion, etc.). A low pass spatial filter smooths extracted transient data and a final logarithmic compression enhances low transient events thus enhancing event sensitivity.
|
||||
|
||||
* **parasolCells_beta** generally set to zero, can be considered as an amplifier gain at the entry point of this processing stage. Generally set to 0.
|
||||
|
||||
* **parasolCells_tau** the temporal smoothing effect that can be added
|
||||
|
||||
* **parasolCells_k** the spatial constant of the spatial filtering effect, set it at a high value to favor low spatial frequency signals that are lower subject to residual noise.
|
||||
|
||||
* **amacrinCellsTemporalCutFrequency** specifies the temporal constant of the high pass filter. High values let slow transient events to be selected.
|
||||
|
||||
* **V0CompressionParameter** specifies the strength of the log compression. Similar behaviors to previous description but here it enforces sensitivity of transient events.
|
||||
|
||||
* **localAdaptintegration_tau** generally set to 0, no real use here actually
|
||||
|
||||
* **localAdaptintegration_k** specifies the size of the area on which local adaptation is performed. Low values lead to short range local adaptation (higher sensitivity to noise), high values secure log compression.
|
@ -110,7 +110,7 @@ bool HdrDecoder::checkSignature( const String& signature ) const
|
||||
|
||||
ImageDecoder HdrDecoder::newDecoder() const
|
||||
{
|
||||
return new HdrDecoder;
|
||||
return makePtr<HdrDecoder>();
|
||||
}
|
||||
|
||||
HdrEncoder::HdrEncoder()
|
||||
@ -154,7 +154,7 @@ bool HdrEncoder::write( const Mat& input_img, const std::vector<int>& params )
|
||||
|
||||
ImageEncoder HdrEncoder::newEncoder() const
|
||||
{
|
||||
return new HdrEncoder;
|
||||
return makePtr<HdrEncoder>();
|
||||
}
|
||||
|
||||
bool HdrEncoder::isFormatSupported( int depth ) const {
|
||||
|
@ -59,15 +59,10 @@ struct ImageCodecInitializer
|
||||
{
|
||||
ImageCodecInitializer()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
decoders.push_back( new BmpDecoder );
|
||||
encoders.push_back( new BmpEncoder );
|
||||
decoders.push_back( new HdrDecoder );
|
||||
encoders.push_back( new HdrEncoder );
|
||||
=======
|
||||
decoders.push_back( makePtr<BmpDecoder>() );
|
||||
encoders.push_back( makePtr<BmpEncoder>() );
|
||||
>>>>>>> 99a43257d5912ff215016e1cf5f4e0c2a934b72f
|
||||
decoders.push_back( makePtr<HdrDecoder>() );
|
||||
encoders.push_back( makePtr<HdrEncoder>() );
|
||||
#ifdef HAVE_JPEG
|
||||
decoders.push_back( makePtr<JpegDecoder>() );
|
||||
encoders.push_back( makePtr<JpegEncoder>() );
|
||||
|
@ -83,7 +83,7 @@ enum rgbe_error_codes {
|
||||
};
|
||||
|
||||
/* default error routine. change this to change error handling */
|
||||
static int rgbe_error(int rgbe_error_code, char *msg)
|
||||
static int rgbe_error(int rgbe_error_code, const char *msg)
|
||||
{
|
||||
switch (rgbe_error_code) {
|
||||
case rgbe_read_error:
|
||||
@ -119,7 +119,7 @@ float2rgbe(unsigned char rgbe[4], float red, float green, float blue)
|
||||
rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
|
||||
}
|
||||
else {
|
||||
v = frexp(v,&e) * 256.0/v;
|
||||
v = static_cast<float>(frexp(v,&e) * 256.0/v);
|
||||
rgbe[0] = (unsigned char) (red * v);
|
||||
rgbe[1] = (unsigned char) (green * v);
|
||||
rgbe[2] = (unsigned char) (blue * v);
|
||||
@ -136,7 +136,7 @@ rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4])
|
||||
float f;
|
||||
|
||||
if (rgbe[3]) { /*nonzero pixel*/
|
||||
f = ldexp(1.0,rgbe[3]-(int)(128+8));
|
||||
f = static_cast<float>(ldexp(1.0,rgbe[3]-(int)(128+8)));
|
||||
*red = rgbe[0] * f;
|
||||
*green = rgbe[1] * f;
|
||||
*blue = rgbe[2] * f;
|
||||
@ -148,7 +148,7 @@ rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4])
|
||||
/* default minimal header. modify if you want more information in header */
|
||||
int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info)
|
||||
{
|
||||
char *programtype = "RGBE";
|
||||
const char *programtype = "RGBE";
|
||||
|
||||
if (info && (info->valid & RGBE_VALID_PROGRAMTYPE))
|
||||
programtype = info->programtype;
|
||||
@ -174,11 +174,9 @@ int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info)
|
||||
int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info)
|
||||
{
|
||||
char buf[128];
|
||||
int found_format;
|
||||
float tempf;
|
||||
int i;
|
||||
|
||||
found_format = 0;
|
||||
if (info) {
|
||||
info->valid = 0;
|
||||
info->programtype[0] = 0;
|
||||
@ -287,7 +285,7 @@ static int RGBE_WriteBytes_RLE(FILE *fp, unsigned char *data, int numbytes)
|
||||
}
|
||||
/* if data before next big run is a short run then write it as such */
|
||||
if ((old_run_count > 1)&&(old_run_count == beg_run - cur)) {
|
||||
buf[0] = 128 + old_run_count; /*write short run*/
|
||||
buf[0] = static_cast<unsigned char>(128 + old_run_count); /*write short run*/
|
||||
buf[1] = data[cur];
|
||||
if (fwrite(buf,sizeof(buf[0])*2,1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
@ -298,7 +296,7 @@ static int RGBE_WriteBytes_RLE(FILE *fp, unsigned char *data, int numbytes)
|
||||
nonrun_count = beg_run - cur;
|
||||
if (nonrun_count > 128)
|
||||
nonrun_count = 128;
|
||||
buf[0] = nonrun_count;
|
||||
buf[0] = static_cast<unsigned char>(nonrun_count);
|
||||
if (fwrite(buf,sizeof(buf[0]),1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
if (fwrite(&data[cur],sizeof(data[0])*nonrun_count,1,fp) < 1)
|
||||
@ -307,7 +305,7 @@ static int RGBE_WriteBytes_RLE(FILE *fp, unsigned char *data, int numbytes)
|
||||
}
|
||||
/* write out next run if one was found */
|
||||
if (run_count >= MINRUNLENGTH) {
|
||||
buf[0] = 128 + run_count;
|
||||
buf[0] = static_cast<unsigned char>(128 + run_count);
|
||||
buf[1] = data[beg_run];
|
||||
if (fwrite(buf,sizeof(buf[0])*2,1,fp) < 1)
|
||||
return rgbe_error(rgbe_write_error,NULL);
|
||||
@ -335,7 +333,7 @@ int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
while(num_scanlines-- > 0) {
|
||||
rgbe[0] = 2;
|
||||
rgbe[1] = 2;
|
||||
rgbe[2] = scanline_width >> 8;
|
||||
rgbe[2] = static_cast<unsigned char>(scanline_width >> 8);
|
||||
rgbe[3] = scanline_width & 0xFF;
|
||||
if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1) {
|
||||
free(buffer);
|
||||
@ -450,4 +448,3 @@ int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
free(scanline_buffer);
|
||||
return RGBE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,3 @@ int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
|
||||
int num_scanlines);
|
||||
|
||||
#endif/*_RGBE_HDR_H_*/
|
||||
|
||||
|
||||
|
||||
|
@ -479,11 +479,7 @@ TEST(Highgui_WebP, encode_decode_lossless_webp)
|
||||
TEST(Highgui_WebP, encode_decode_lossy_webp)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
<<<<<<< HEAD
|
||||
string input = string(ts.get_data_path()) + "/../cv/shared/lena.png";
|
||||
=======
|
||||
std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
|
||||
>>>>>>> 99a43257d5912ff215016e1cf5f4e0c2a934b72f
|
||||
cv::Mat img = cv::imread(input);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
|
@ -46,7 +46,7 @@ createTonemapDrago
|
||||
---------------------------
|
||||
Creates TonemapDrago object
|
||||
|
||||
.. ocv:function:: Ptr<TonemapDrago> createTonemapDrago(float gamma = 1.0f, float bias = 0.85f)
|
||||
.. ocv:function:: Ptr<TonemapDrago> createTonemapDrago(float gamma = 1.0f, float saturation = 1.0f, float bias = 0.85f)
|
||||
|
||||
:param gamma: gamma value for gamma correction. See :ocv:func:`createTonemap`
|
||||
|
||||
@ -82,9 +82,9 @@ Creates TonemapDurand object
|
||||
|
||||
:param sigma_color: bilateral filter sigma in coordinate space
|
||||
|
||||
TonemapReinhardDevlin
|
||||
TonemapReinhard
|
||||
---------------------------
|
||||
.. ocv:class:: TonemapReinhardDevlin : public Tonemap
|
||||
.. ocv:class:: TonemapReinhard : public Tonemap
|
||||
|
||||
This is a global tonemapping operator that models human visual system.
|
||||
|
||||
@ -92,11 +92,11 @@ Mapping function is controlled by adaptation parameter, that is computed using l
|
||||
|
||||
For more information see [RD05]_.
|
||||
|
||||
createTonemapReinhardDevlin
|
||||
createTonemapReinhard
|
||||
---------------------------
|
||||
Creates TonemapReinhardDevlin object
|
||||
Creates TonemapReinhard object
|
||||
|
||||
.. ocv:function:: Ptr<TonemapReinhardDevlin> createTonemapReinhardDevlin(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f)
|
||||
.. ocv:function:: Ptr<TonemapReinhard> createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f)
|
||||
|
||||
:param gamma: gamma value for gamma correction. See :ocv:func:`createTonemap`
|
||||
|
||||
@ -127,17 +127,17 @@ Creates TonemapMantiuk object
|
||||
|
||||
:param saturation: saturation enhancement value. See :ocv:func:`createTonemapDrago`
|
||||
|
||||
ExposureAlign
|
||||
AlignExposures
|
||||
---------------------------
|
||||
.. ocv:class:: ExposureAlign : public Algorithm
|
||||
.. ocv:class:: AlignExposures : public Algorithm
|
||||
|
||||
The base class for algorithms that align images of the same scene with different exposures
|
||||
|
||||
ExposureAlign::process
|
||||
AlignExposures::process
|
||||
---------------------------
|
||||
Aligns images
|
||||
|
||||
.. ocv:function:: void ExposureAlign::process(InputArrayOfArrays src, OutputArrayOfArrays dst, const std::vector<float>& times, InputArray response)
|
||||
.. ocv:function:: void AlignExposures::process(InputArrayOfArrays src, std::vector<Mat>& dst, InputArray times, InputArray response)
|
||||
|
||||
:param src: vector of input images
|
||||
|
||||
@ -149,7 +149,7 @@ Aligns images
|
||||
|
||||
AlignMTB
|
||||
---------------------------
|
||||
.. ocv:class:: AlignMTB : public ExposureAlign
|
||||
.. ocv:class:: AlignMTB : public AlignExposures
|
||||
|
||||
This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.
|
||||
|
||||
@ -163,7 +163,7 @@ AlignMTB::process
|
||||
---------------------------
|
||||
Short version of process, that doesn't take extra arguments.
|
||||
|
||||
.. ocv:function:: void AlignMTB::process(InputArrayOfArrays src, OutputArrayOfArrays dst)
|
||||
.. ocv:function:: void AlignMTB::process(InputArrayOfArrays src, std::vector<Mat>& dst)
|
||||
|
||||
:param src: vector of input images
|
||||
|
||||
@ -173,14 +173,12 @@ AlignMTB::calculateShift
|
||||
---------------------------
|
||||
Calculates shift between two images, i. e. how to shift the second image to correspond it with the first.
|
||||
|
||||
.. ocv:function:: void AlignMTB::calculateShift(InputArray img0, InputArray img1, Point& shift)
|
||||
.. ocv:function:: Point AlignMTB::calculateShift(InputArray img0, InputArray img1)
|
||||
|
||||
:param img0: first image
|
||||
|
||||
:param img1: second image
|
||||
|
||||
:param shift: calculated shift
|
||||
|
||||
AlignMTB::shiftMat
|
||||
---------------------------
|
||||
Helper function, that shift Mat filling new regions with zeros.
|
||||
@ -197,7 +195,7 @@ AlignMTB::computeBitmaps
|
||||
---------------------------
|
||||
Computes median threshold and exclude bitmaps of given image.
|
||||
|
||||
.. ocv:function:: void computeBitmaps(Mat& img, Mat& tb, Mat& eb)
|
||||
.. ocv:function:: void AlignMTB::computeBitmaps(InputArray img, OutputArray tb, OutputArray eb)
|
||||
|
||||
:param img: input image
|
||||
|
||||
@ -217,17 +215,17 @@ Creates AlignMTB object
|
||||
|
||||
:param cut: if true cuts images, otherwise fills the new regions with zeros.
|
||||
|
||||
ExposureCalibrate
|
||||
CalibrateCRF
|
||||
---------------------------
|
||||
.. ocv:class:: ExposureCalibrate : public Algorithm
|
||||
.. ocv:class:: CalibrateCRF : public Algorithm
|
||||
|
||||
The base class for camera response calibration algorithms.
|
||||
|
||||
ExposureCalibrate::process
|
||||
CalibrateCRF::process
|
||||
---------------------------
|
||||
Recovers inverse camera response.
|
||||
|
||||
.. ocv:function:: void ExposureCalibrate::process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times)
|
||||
.. ocv:function:: void CalibrateCRF::process(InputArrayOfArrays src, OutputArray dst, InputArray times)
|
||||
|
||||
:param src: vector of input images
|
||||
|
||||
@ -237,7 +235,7 @@ Recovers inverse camera response.
|
||||
|
||||
CalibrateDebevec
|
||||
---------------------------
|
||||
.. ocv:class:: CalibrateDebevec : public ExposureCalibrate
|
||||
.. ocv:class:: CalibrateDebevec : public CalibrateCRF
|
||||
|
||||
Inverse camera response function is extracted for each brightness value by minimizing an objective function as linear system.
|
||||
Objective function is constructed using pixel values on the same position in all images, extra term is added to make the result smoother.
|
||||
@ -258,7 +256,7 @@ Creates CalibrateDebevec object
|
||||
|
||||
CalibrateRobertson
|
||||
---------------------------
|
||||
.. ocv:class:: CalibrateRobertson : public ExposureCalibrate
|
||||
.. ocv:class:: CalibrateRobertson : public CalibrateCRF
|
||||
|
||||
Inverse camera response function is extracted for each brightness value by minimizing an objective function as linear system.
|
||||
This algorithm uses all image pixels.
|
||||
@ -275,17 +273,17 @@ Creates CalibrateRobertson object
|
||||
|
||||
:param threshold: target difference between results of two successive steps of the minimization.
|
||||
|
||||
ExposureMerge
|
||||
MergeExposures
|
||||
---------------------------
|
||||
.. ocv:class:: ExposureMerge : public Algorithm
|
||||
.. ocv:class:: MergeExposures : public Algorithm
|
||||
|
||||
The base class algorithms that can merge exposure sequence to a single image.
|
||||
|
||||
ExposureMerge::process
|
||||
MergeExposures::process
|
||||
---------------------------
|
||||
Merges images.
|
||||
|
||||
.. ocv:function:: void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times, InputArray response)
|
||||
.. ocv:function:: void MergeExposures::process(InputArrayOfArrays src, OutputArray dst, InputArray times, InputArray response)
|
||||
|
||||
:param src: vector of input images
|
||||
|
||||
@ -297,7 +295,7 @@ Merges images.
|
||||
|
||||
MergeDebevec
|
||||
---------------------------
|
||||
.. ocv:class:: MergeDebevec : public ExposureMerge
|
||||
.. ocv:class:: MergeDebevec : public MergeExposures
|
||||
|
||||
The resulting HDR image is calculated as weighted average of the exposures considering exposure values and camera response.
|
||||
|
||||
@ -311,7 +309,7 @@ Creates MergeDebevec object
|
||||
|
||||
MergeMertens
|
||||
---------------------------
|
||||
.. ocv:class:: MergeMertens : public ExposureMerge
|
||||
.. ocv:class:: MergeMertens : public MergeExposures
|
||||
|
||||
Pixels are weighted using contrast, saturation and well-exposedness measures, than images are combined using laplacian pyramids.
|
||||
|
||||
@ -345,7 +343,7 @@ Creates MergeMertens object
|
||||
|
||||
MergeRobertson
|
||||
---------------------------
|
||||
.. ocv:class:: MergeRobertson : public ExposureMerge
|
||||
.. ocv:class:: MergeRobertson : public MergeExposures
|
||||
|
||||
The resulting HDR image is calculated as weighted average of the exposures considering exposure values and camera response.
|
||||
|
||||
@ -364,7 +362,7 @@ References
|
||||
|
||||
.. [FL02] R. Fattal, D. Lischinski, M. Werman, "Gradient Domain High Dynamic Range Compression", Proceedings OF ACM SIGGRAPH, 2002, 249 - 256.
|
||||
|
||||
.. [DD02] F. Durand and Julie Dorsey, "Fast Bilateral Filtering for the Display of High-Dynamic-Range Images", ACM Transactions on Graphics, 2002, 21, 3, 257 - 266.
|
||||
.. [DD02] F. Durand and Julie Dorsey, "Fast Bilateral Filtering for the Display of High-Dynamic-Range Images", ACM Transactions on Graphics, 2002, 21, 3, 257 - 266.
|
||||
|
||||
.. [RD05] E. Reinhard, K. Devlin, "Dynamic Range Reduction Inspired by Photoreceptor Physiology", IEEE Transactions on Visualization and Computer Graphics, 2005, 11, 13 - 24.
|
||||
|
||||
|
@ -132,7 +132,7 @@ createTonemapDurand(float gamma = 1.0f, float contrast = 4.0f, float saturation
|
||||
|
||||
// "Dynamic Range Reduction Inspired by Photoreceptor Physiology", Reinhard, Devlin, 2005
|
||||
|
||||
class CV_EXPORTS_W TonemapReinhardDevlin : public Tonemap
|
||||
class CV_EXPORTS_W TonemapReinhard : public Tonemap
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual float getIntensity() const = 0;
|
||||
@ -145,8 +145,8 @@ public:
|
||||
CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0;
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Ptr<TonemapReinhardDevlin>
|
||||
createTonemapReinhardDevlin(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f);
|
||||
CV_EXPORTS_W Ptr<TonemapReinhard>
|
||||
createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f);
|
||||
|
||||
// "Perceptual Framework for Contrast Processing of High Dynamic Range Images", Mantiuk et al., 2006
|
||||
|
||||
@ -163,26 +163,26 @@ public:
|
||||
CV_EXPORTS_W Ptr<TonemapMantiuk>
|
||||
createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f);
|
||||
|
||||
class CV_EXPORTS_W ExposureAlign : public Algorithm
|
||||
class CV_EXPORTS_W AlignExposures : public Algorithm
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
|
||||
const std::vector<float>& times, InputArray response) = 0;
|
||||
InputArray times, InputArray response) = 0;
|
||||
};
|
||||
|
||||
// "Fast, Robust Image Registration for Compositing High Dynamic Range Photographs from Handheld Exposures", Ward, 2003
|
||||
|
||||
class CV_EXPORTS_W AlignMTB : public ExposureAlign
|
||||
class CV_EXPORTS_W AlignMTB : public AlignExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
|
||||
const std::vector<float>& times, InputArray response) = 0;
|
||||
InputArray times, InputArray response) = 0;
|
||||
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst) = 0;
|
||||
|
||||
CV_WRAP virtual void calculateShift(InputArray img0, InputArray img1, Point& shift) = 0;
|
||||
CV_WRAP virtual Point calculateShift(InputArray img0, InputArray img1) = 0;
|
||||
CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0;
|
||||
CV_WRAP virtual void computeBitmaps(Mat& img, Mat& tb, Mat& eb) = 0;
|
||||
CV_WRAP virtual void computeBitmaps(InputArray img, OutputArray tb, OutputArray eb) = 0;
|
||||
|
||||
CV_WRAP virtual int getMaxBits() const = 0;
|
||||
CV_WRAP virtual void setMaxBits(int max_bits) = 0;
|
||||
@ -196,15 +196,15 @@ public:
|
||||
|
||||
CV_EXPORTS_W Ptr<AlignMTB> createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true);
|
||||
|
||||
class CV_EXPORTS_W ExposureCalibrate : public Algorithm
|
||||
class CV_EXPORTS_W CalibrateCRF : public Algorithm
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times) = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
|
||||
};
|
||||
|
||||
// "Recovering High Dynamic Range Radiance Maps from Photographs", Debevec, Malik, 1997
|
||||
|
||||
class CV_EXPORTS_W CalibrateDebevec : public ExposureCalibrate
|
||||
class CV_EXPORTS_W CalibrateDebevec : public CalibrateCRF
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual float getLambda() const = 0;
|
||||
@ -221,7 +221,7 @@ CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 70, floa
|
||||
|
||||
// "Dynamic range improvement through multiple exposures", Robertson et al., 1999
|
||||
|
||||
class CV_EXPORTS_W CalibrateRobertson : public ExposureCalibrate
|
||||
class CV_EXPORTS_W CalibrateRobertson : public CalibrateCRF
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual int getMaxIter() const = 0;
|
||||
@ -235,32 +235,32 @@ public:
|
||||
|
||||
CV_EXPORTS_W Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f);
|
||||
|
||||
class CV_EXPORTS_W ExposureMerge : public Algorithm
|
||||
class CV_EXPORTS_W MergeExposures : public Algorithm
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
const std::vector<float>& times, InputArray response) = 0;
|
||||
InputArray times, InputArray response) = 0;
|
||||
};
|
||||
|
||||
// "Recovering High Dynamic Range Radiance Maps from Photographs", Debevec, Malik, 1997
|
||||
|
||||
class CV_EXPORTS_W MergeDebevec : public ExposureMerge
|
||||
class CV_EXPORTS_W MergeDebevec : public MergeExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
const std::vector<float>& times, InputArray response) = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times) = 0;
|
||||
InputArray times, InputArray response) = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Ptr<MergeDebevec> createMergeDebevec();
|
||||
|
||||
// "Exposure Fusion", Mertens et al., 2007
|
||||
|
||||
class CV_EXPORTS_W MergeMertens : public ExposureMerge
|
||||
class CV_EXPORTS_W MergeMertens : public MergeExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
const std::vector<float>& times, InputArray response) = 0;
|
||||
InputArray times, InputArray response) = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0;
|
||||
|
||||
CV_WRAP virtual float getContrastWeight() const = 0;
|
||||
@ -278,12 +278,12 @@ createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f,
|
||||
|
||||
// "Dynamic range improvement through multiple exposures", Robertson et al., 1999
|
||||
|
||||
class CV_EXPORTS_W MergeRobertson : public ExposureMerge
|
||||
class CV_EXPORTS_W MergeRobertson : public MergeExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
const std::vector<float>& times, InputArray response) = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times) = 0;
|
||||
InputArray times, InputArray response) = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Ptr<MergeRobertson> createMergeRobertson();
|
||||
|
@ -50,16 +50,16 @@ namespace cv
|
||||
class AlignMTBImpl : public AlignMTB
|
||||
{
|
||||
public:
|
||||
AlignMTBImpl(int max_bits, int exclude_range, bool cut) :
|
||||
max_bits(max_bits),
|
||||
exclude_range(exclude_range),
|
||||
cut(cut),
|
||||
name("AlignMTB")
|
||||
AlignMTBImpl(int _max_bits, int _exclude_range, bool _cut) :
|
||||
name("AlignMTB"),
|
||||
max_bits(_max_bits),
|
||||
exclude_range(_exclude_range),
|
||||
cut(_cut)
|
||||
{
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, std::vector<Mat>& dst,
|
||||
const std::vector<float>& times, InputArray response)
|
||||
InputArray, InputArray)
|
||||
{
|
||||
process(src, dst);
|
||||
}
|
||||
@ -85,8 +85,7 @@ public:
|
||||
}
|
||||
Mat gray;
|
||||
cvtColor(src[i], gray, COLOR_RGB2GRAY);
|
||||
Point shift;
|
||||
calculateShift(gray_base, gray, shift);
|
||||
Point shift = calculateShift(gray_base, gray);
|
||||
shifts.push_back(shift);
|
||||
shiftMat(src[i], dst[i], shift);
|
||||
}
|
||||
@ -113,7 +112,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void calculateShift(InputArray _img0, InputArray _img1, Point& shift)
|
||||
Point calculateShift(InputArray _img0, InputArray _img1)
|
||||
{
|
||||
Mat img0 = _img0.getMat();
|
||||
Mat img1 = _img1.getMat();
|
||||
@ -128,7 +127,7 @@ public:
|
||||
buildPyr(img0, pyr0, maxlevel);
|
||||
buildPyr(img1, pyr1, maxlevel);
|
||||
|
||||
shift = Point(0, 0);
|
||||
Point shift(0, 0);
|
||||
for(int level = maxlevel; level >= 0; level--) {
|
||||
|
||||
shift *= 2;
|
||||
@ -156,6 +155,7 @@ public:
|
||||
}
|
||||
shift = new_shift;
|
||||
}
|
||||
return shift;
|
||||
}
|
||||
|
||||
void shiftMat(InputArray _src, OutputArray _dst, const Point shift)
|
||||
@ -197,11 +197,15 @@ public:
|
||||
max_bits = fn["max_bits"];
|
||||
exclude_range = fn["exclude_range"];
|
||||
int cut_val = fn["cut"];
|
||||
cut = static_cast<bool>(cut_val);
|
||||
cut = (cut_val != 0);
|
||||
}
|
||||
|
||||
void computeBitmaps(Mat& img, Mat& tb, Mat& eb)
|
||||
void computeBitmaps(InputArray _img, OutputArray _tb, OutputArray _eb)
|
||||
{
|
||||
Mat img = _img.getMat();
|
||||
_tb.create(img.size(), CV_8U);
|
||||
_eb.create(img.size(), CV_8U);
|
||||
Mat tb = _tb.getMat(), eb = _eb.getMat();
|
||||
int median = getMedian(img);
|
||||
compare(img, median, tb, CMP_GT);
|
||||
compare(abs(img - median), exclude_range, eb, CMP_GT);
|
||||
@ -260,8 +264,7 @@ protected:
|
||||
|
||||
Ptr<AlignMTB> createAlignMTB(int max_bits, int exclude_range, bool cut)
|
||||
{
|
||||
return new AlignMTBImpl(max_bits, exclude_range, cut);
|
||||
return makePtr<AlignMTBImpl>(max_bits, exclude_range, cut);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,21 +52,22 @@ namespace cv
|
||||
class CalibrateDebevecImpl : public CalibrateDebevec
|
||||
{
|
||||
public:
|
||||
CalibrateDebevecImpl(int samples, float lambda, bool random) :
|
||||
samples(samples),
|
||||
lambda(lambda),
|
||||
CalibrateDebevecImpl(int _samples, float _lambda, bool _random) :
|
||||
name("CalibrateDebevec"),
|
||||
w(tringleWeights()),
|
||||
random(random)
|
||||
samples(_samples),
|
||||
lambda(_lambda),
|
||||
random(_random),
|
||||
w(tringleWeights())
|
||||
{
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times)
|
||||
void process(InputArrayOfArrays src, OutputArray dst, InputArray _times)
|
||||
{
|
||||
std::vector<Mat> images;
|
||||
src.getMatVector(images);
|
||||
Mat times = _times.getMat();
|
||||
|
||||
CV_Assert(images.size() == times.size());
|
||||
CV_Assert(images.size() == times.total());
|
||||
checkImageDimensions(images);
|
||||
CV_Assert(images[0].depth() == CV_8U);
|
||||
|
||||
@ -82,7 +83,7 @@ public:
|
||||
sample_points.push_back(Point(rand() % images[0].cols, rand() % images[0].rows));
|
||||
}
|
||||
} else {
|
||||
int x_points = sqrt(static_cast<double>(samples) * images[0].cols / images[0].rows);
|
||||
int x_points = static_cast<int>(sqrt(static_cast<double>(samples) * images[0].cols / images[0].rows));
|
||||
int y_points = samples / x_points;
|
||||
int step_x = images[0].cols / x_points;
|
||||
int step_y = images[0].rows / y_points;
|
||||
@ -106,7 +107,7 @@ public:
|
||||
int val = images[j].ptr()[3*(sample_points[i].y * images[j].cols + sample_points[j].x) + channel];
|
||||
A.at<float>(eq, val) = w.at<float>(val);
|
||||
A.at<float>(eq, LDR_SIZE + i) = -w.at<float>(val);
|
||||
B.at<float>(eq, 0) = w.at<float>(val) * log(times[j]);
|
||||
B.at<float>(eq, 0) = w.at<float>(val) * log(times.at<float>(j));
|
||||
eq++;
|
||||
}
|
||||
}
|
||||
@ -151,7 +152,7 @@ public:
|
||||
samples = fn["samples"];
|
||||
lambda = fn["lambda"];
|
||||
int random_val = fn["random"];
|
||||
random = static_cast<bool>(random_val);
|
||||
random = (random_val != 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -164,26 +165,27 @@ protected:
|
||||
|
||||
Ptr<CalibrateDebevec> createCalibrateDebevec(int samples, float lambda, bool random)
|
||||
{
|
||||
return new CalibrateDebevecImpl(samples, lambda, random);
|
||||
return makePtr<CalibrateDebevecImpl>(samples, lambda, random);
|
||||
}
|
||||
|
||||
class CalibrateRobertsonImpl : public CalibrateRobertson
|
||||
{
|
||||
public:
|
||||
CalibrateRobertsonImpl(int max_iter, float threshold) :
|
||||
max_iter(max_iter),
|
||||
threshold(threshold),
|
||||
CalibrateRobertsonImpl(int _max_iter, float _threshold) :
|
||||
name("CalibrateRobertson"),
|
||||
max_iter(_max_iter),
|
||||
threshold(_threshold),
|
||||
weight(RobertsonWeights())
|
||||
{
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times)
|
||||
void process(InputArrayOfArrays src, OutputArray dst, InputArray _times)
|
||||
{
|
||||
std::vector<Mat> images;
|
||||
src.getMatVector(images);
|
||||
Mat times = _times.getMat();
|
||||
|
||||
CV_Assert(images.size() == times.size());
|
||||
CV_Assert(images.size() == times.total());
|
||||
checkImageDimensions(images);
|
||||
CV_Assert(images[0].depth() == CV_8U);
|
||||
|
||||
@ -217,7 +219,7 @@ public:
|
||||
float* rad_ptr = radiance.ptr<float>();
|
||||
for(size_t pos = 0; pos < images[i].total(); pos++) {
|
||||
for(int c = 0; c < channels; c++, ptr++, rad_ptr++) {
|
||||
new_response.at<Vec3f>(*ptr)[c] += times[i] * *rad_ptr;
|
||||
new_response.at<Vec3f>(*ptr)[c] += times.at<float>(i) * *rad_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,7 +230,7 @@ public:
|
||||
new_response.at<Vec3f>(i)[c] /= middle;
|
||||
}
|
||||
}
|
||||
float diff = sum(sum(abs(new_response - response)))[0] / channels;
|
||||
float diff = static_cast<float>(sum(sum(abs(new_response - response)))[0] / channels);
|
||||
new_response.copyTo(response);
|
||||
if(diff < threshold) {
|
||||
break;
|
||||
@ -268,7 +270,7 @@ protected:
|
||||
|
||||
Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter, float threshold)
|
||||
{
|
||||
return new CalibrateRobertsonImpl(max_iter, threshold);
|
||||
return makePtr<CalibrateRobertsonImpl>(max_iter, threshold);
|
||||
}
|
||||
|
||||
}
|
@ -97,7 +97,7 @@ Mat linearResponse(int channels)
|
||||
{
|
||||
Mat response = Mat(LDR_SIZE, 1, CV_MAKETYPE(CV_32F, channels));
|
||||
for(int i = 0; i < LDR_SIZE; i++) {
|
||||
response.at<Vec3f>(i) = Vec3f::all(i);
|
||||
response.at<Vec3f>(i) = Vec3f::all(static_cast<float>(i));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
@ -56,12 +56,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times, InputArray input_response)
|
||||
void process(InputArrayOfArrays src, OutputArray dst, InputArray _times, InputArray input_response)
|
||||
{
|
||||
std::vector<Mat> images;
|
||||
src.getMatVector(images);
|
||||
Mat times = _times.getMat();
|
||||
|
||||
CV_Assert(images.size() == times.size());
|
||||
CV_Assert(images.size() == times.total());
|
||||
checkImageDimensions(images);
|
||||
CV_Assert(images[0].depth() == CV_8U);
|
||||
|
||||
@ -117,7 +118,7 @@ public:
|
||||
exp(result, result);
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times)
|
||||
void process(InputArrayOfArrays src, OutputArray dst, InputArray times)
|
||||
{
|
||||
process(src, dst, times, Mat());
|
||||
}
|
||||
@ -129,21 +130,21 @@ protected:
|
||||
|
||||
Ptr<MergeDebevec> createMergeDebevec()
|
||||
{
|
||||
return new MergeDebevecImpl;
|
||||
return makePtr<MergeDebevecImpl>();
|
||||
}
|
||||
|
||||
class MergeMertensImpl : public MergeMertens
|
||||
{
|
||||
public:
|
||||
MergeMertensImpl(float wcon, float wsat, float wexp) :
|
||||
wcon(wcon),
|
||||
wsat(wsat),
|
||||
wexp(wexp),
|
||||
name("MergeMertens")
|
||||
MergeMertensImpl(float _wcon, float _wsat, float _wexp) :
|
||||
name("MergeMertens"),
|
||||
wcon(_wcon),
|
||||
wsat(_wsat),
|
||||
wexp(_wexp)
|
||||
{
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArrayOfArrays dst, const std::vector<float>& times, InputArray response)
|
||||
void process(InputArrayOfArrays src, OutputArrayOfArrays dst, InputArray, InputArray)
|
||||
{
|
||||
process(src, dst);
|
||||
}
|
||||
@ -283,7 +284,7 @@ protected:
|
||||
|
||||
Ptr<MergeMertens> createMergeMertens(float wcon, float wsat, float wexp)
|
||||
{
|
||||
return new MergeMertensImpl(wcon, wsat, wexp);
|
||||
return makePtr<MergeMertensImpl>(wcon, wsat, wexp);
|
||||
}
|
||||
|
||||
class MergeRobertsonImpl : public MergeRobertson
|
||||
@ -295,12 +296,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times, InputArray input_response)
|
||||
void process(InputArrayOfArrays src, OutputArray dst, InputArray _times, InputArray input_response)
|
||||
{
|
||||
std::vector<Mat> images;
|
||||
src.getMatVector(images);
|
||||
Mat times = _times.getMat();
|
||||
|
||||
CV_Assert(images.size() == times.size());
|
||||
CV_Assert(images.size() == times.total());
|
||||
checkImageDimensions(images);
|
||||
CV_Assert(images[0].depth() == CV_8U);
|
||||
|
||||
@ -312,7 +314,8 @@ public:
|
||||
|
||||
Mat response = input_response.getMat();
|
||||
if(response.empty()) {
|
||||
response = linearResponse(channels) / (LDR_SIZE / 2.0f);
|
||||
float middle = LDR_SIZE / 2.0f;
|
||||
response = linearResponse(channels) / middle;
|
||||
}
|
||||
CV_Assert(response.rows == LDR_SIZE && response.cols == 1 &&
|
||||
response.channels() == channels);
|
||||
@ -324,13 +327,13 @@ public:
|
||||
LUT(images[i], weight, w);
|
||||
LUT(images[i], response, im);
|
||||
|
||||
result += times[i] * w.mul(im);
|
||||
wsum += pow(times[i], 2) * w;
|
||||
result += times.at<float>(i) * w.mul(im);
|
||||
wsum += times.at<float>(i) * times.at<float>(i) * w;
|
||||
}
|
||||
result = result.mul(1 / wsum);
|
||||
}
|
||||
|
||||
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times)
|
||||
void process(InputArrayOfArrays src, OutputArray dst, InputArray times)
|
||||
{
|
||||
process(src, dst, times, Mat());
|
||||
}
|
||||
@ -342,7 +345,7 @@ protected:
|
||||
|
||||
Ptr<MergeRobertson> createMergeRobertson()
|
||||
{
|
||||
return new MergeRobertsonImpl;
|
||||
return makePtr<MergeRobertsonImpl>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace cv
|
||||
class TonemapImpl : public Tonemap
|
||||
{
|
||||
public:
|
||||
TonemapImpl(float gamma) : gamma(gamma), name("Tonemap")
|
||||
TonemapImpl(float _gamma) : name("Tonemap"), gamma(_gamma)
|
||||
{
|
||||
}
|
||||
|
||||
@ -95,17 +95,17 @@ protected:
|
||||
|
||||
Ptr<Tonemap> createTonemap(float gamma)
|
||||
{
|
||||
return new TonemapImpl(gamma);
|
||||
return makePtr<TonemapImpl>(gamma);
|
||||
}
|
||||
|
||||
class TonemapDragoImpl : public TonemapDrago
|
||||
{
|
||||
public:
|
||||
TonemapDragoImpl(float gamma, float saturation, float bias) :
|
||||
gamma(gamma),
|
||||
saturation(saturation),
|
||||
bias(bias),
|
||||
name("TonemapDrago")
|
||||
TonemapDragoImpl(float _gamma, float _saturation, float _bias) :
|
||||
name("TonemapDrago"),
|
||||
gamma(_gamma),
|
||||
saturation(_saturation),
|
||||
bias(_bias)
|
||||
{
|
||||
}
|
||||
|
||||
@ -177,19 +177,19 @@ protected:
|
||||
|
||||
Ptr<TonemapDrago> createTonemapDrago(float gamma, float saturation, float bias)
|
||||
{
|
||||
return new TonemapDragoImpl(gamma, saturation, bias);
|
||||
return makePtr<TonemapDragoImpl>(gamma, saturation, bias);
|
||||
}
|
||||
|
||||
class TonemapDurandImpl : public TonemapDurand
|
||||
{
|
||||
public:
|
||||
TonemapDurandImpl(float gamma, float contrast, float saturation, float sigma_color, float sigma_space) :
|
||||
gamma(gamma),
|
||||
contrast(contrast),
|
||||
saturation(saturation),
|
||||
sigma_color(sigma_color),
|
||||
sigma_space(sigma_space),
|
||||
name("TonemapDurand")
|
||||
TonemapDurandImpl(float _gamma, float _contrast, float _saturation, float _sigma_color, float _sigma_space) :
|
||||
name("TonemapDurand"),
|
||||
gamma(_gamma),
|
||||
contrast(_contrast),
|
||||
saturation(_saturation),
|
||||
sigma_color(_sigma_color),
|
||||
sigma_space(_sigma_space)
|
||||
{
|
||||
}
|
||||
|
||||
@ -257,23 +257,23 @@ public:
|
||||
|
||||
protected:
|
||||
String name;
|
||||
float gamma, saturation, contrast, sigma_color, sigma_space;
|
||||
float gamma, contrast, saturation, sigma_color, sigma_space;
|
||||
};
|
||||
|
||||
Ptr<TonemapDurand> createTonemapDurand(float gamma, float contrast, float saturation, float sigma_color, float sigma_space)
|
||||
{
|
||||
return new TonemapDurandImpl(gamma, contrast, saturation, sigma_color, sigma_space);
|
||||
return makePtr<TonemapDurandImpl>(gamma, contrast, saturation, sigma_color, sigma_space);
|
||||
}
|
||||
|
||||
class TonemapReinhardDevlinImpl : public TonemapReinhardDevlin
|
||||
class TonemapReinhardImpl : public TonemapReinhard
|
||||
{
|
||||
public:
|
||||
TonemapReinhardDevlinImpl(float gamma, float intensity, float light_adapt, float color_adapt) :
|
||||
gamma(gamma),
|
||||
intensity(intensity),
|
||||
light_adapt(light_adapt),
|
||||
color_adapt(color_adapt),
|
||||
name("TonemapReinhardDevlin")
|
||||
TonemapReinhardImpl(float _gamma, float _intensity, float _light_adapt, float _color_adapt) :
|
||||
name("TonemapReinhard"),
|
||||
gamma(_gamma),
|
||||
intensity(_intensity),
|
||||
light_adapt(_light_adapt),
|
||||
color_adapt(_color_adapt)
|
||||
{
|
||||
}
|
||||
|
||||
@ -355,19 +355,19 @@ protected:
|
||||
float gamma, intensity, light_adapt, color_adapt;
|
||||
};
|
||||
|
||||
Ptr<TonemapReinhardDevlin> createTonemapReinhardDevlin(float gamma, float contrast, float sigma_color, float sigma_space)
|
||||
Ptr<TonemapReinhard> createTonemapReinhard(float gamma, float contrast, float sigma_color, float sigma_space)
|
||||
{
|
||||
return new TonemapReinhardDevlinImpl(gamma, contrast, sigma_color, sigma_space);
|
||||
return makePtr<TonemapReinhardImpl>(gamma, contrast, sigma_color, sigma_space);
|
||||
}
|
||||
|
||||
class TonemapMantiukImpl : public TonemapMantiuk
|
||||
{
|
||||
public:
|
||||
TonemapMantiukImpl(float gamma, float scale, float saturation) :
|
||||
gamma(gamma),
|
||||
scale(scale),
|
||||
saturation(saturation),
|
||||
name("TonemapMantiuk")
|
||||
TonemapMantiukImpl(float _gamma, float _scale, float _saturation) :
|
||||
name("TonemapMantiuk"),
|
||||
gamma(_gamma),
|
||||
scale(_scale),
|
||||
saturation(_saturation)
|
||||
{
|
||||
}
|
||||
|
||||
@ -389,8 +389,8 @@ public:
|
||||
getContrast(log_img, x_contrast, y_contrast);
|
||||
|
||||
for(size_t i = 0; i < x_contrast.size(); i++) {
|
||||
mapContrast(x_contrast[i], scale);
|
||||
mapContrast(y_contrast[i], scale);
|
||||
mapContrast(x_contrast[i]);
|
||||
mapContrast(y_contrast[i]);
|
||||
}
|
||||
|
||||
Mat right(src.size(), CV_32F);
|
||||
@ -468,7 +468,7 @@ protected:
|
||||
dst = dst.mul(sign);
|
||||
}
|
||||
|
||||
void mapContrast(Mat& contrast, float scale)
|
||||
void mapContrast(Mat& contrast)
|
||||
{
|
||||
const float response_power = 0.4185f;
|
||||
signedPow(contrast, response_power, contrast);
|
||||
@ -525,7 +525,7 @@ protected:
|
||||
|
||||
Ptr<TonemapMantiuk> createTonemapMantiuk(float gamma, float scale, float saturation)
|
||||
{
|
||||
return new TonemapMantiukImpl(gamma, scale, saturation);
|
||||
return makePtr<TonemapMantiukImpl>(gamma, scale, saturation);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ TEST(Photo_Tonemap, regression)
|
||||
result.convertTo(result, CV_8UC3, 255);
|
||||
checkEqual(result, expected, 3);
|
||||
|
||||
Ptr<TonemapReinhardDevlin> reinhard_devlin = createTonemapReinhardDevlin(gamma);
|
||||
reinhard_devlin->process(img, result);
|
||||
loadImage(test_path + "reinharddevlin.png", expected);
|
||||
Ptr<TonemapReinhard> reinhard = createTonemapReinhard(gamma);
|
||||
reinhard->process(img, result);
|
||||
loadImage(test_path + "reinhard.png", expected);
|
||||
result.convertTo(result, CV_8UC3, 255);
|
||||
checkEqual(result, expected, 3);
|
||||
|
||||
@ -149,8 +149,7 @@ TEST(Photo_AlignMTB, regression)
|
||||
Point shift(rand() % max_shift, rand() % max_shift);
|
||||
Mat res;
|
||||
align->shiftMat(img, res, shift);
|
||||
Point calc;
|
||||
align->calculateShift(img, res, calc);
|
||||
Point calc = align->calculateShift(img, res);
|
||||
errors += (calc != -shift);
|
||||
}
|
||||
ASSERT_TRUE(errors < 5) << errors << " errors";
|
||||
|
@ -137,14 +137,16 @@ typedef Ptr<StereoSGBM> Ptr_StereoSGBM;
|
||||
|
||||
typedef Ptr<Tonemap> Ptr_Tonemap;
|
||||
typedef Ptr<TonemapDrago> Ptr_TonemapDrago;
|
||||
typedef Ptr<TonemapReinhardDevlin> Ptr_TonemapReinhardDevlin;
|
||||
typedef Ptr<TonemapReinhard> Ptr_TonemapReinhard;
|
||||
typedef Ptr<TonemapDurand> Ptr_TonemapDurand;
|
||||
typedef Ptr<TonemapMantiuk> Ptr_TonemapMantiuk;
|
||||
typedef Ptr<AlignMTB> Ptr_AlignMTB;
|
||||
typedef Ptr<CalibrateDebevec> Ptr_CalibrateDebevec;
|
||||
typedef Ptr<CalibrateRobertson> Ptr_CalibrateRobertson;
|
||||
typedef Ptr<MergeDebevec> Ptr_MergeDebevec;
|
||||
typedef Ptr<MergeRobertson> Ptr_MergeRobertson;
|
||||
typedef Ptr<MergeMertens> Ptr_MergeMertens;
|
||||
typedef Ptr<MergeRobertson> Ptr_MergeRobertson;
|
||||
|
||||
typedef Ptr<cv::softcascade::ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder;
|
||||
typedef Ptr<CLAHE> Ptr_CLAHE;
|
||||
|
@ -7,21 +7,9 @@
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
void loadExposureSeq(String path, vector<Mat>& images, vector<float>& times)
|
||||
{
|
||||
path += "/";
|
||||
ifstream list_file((path + "list.txt").c_str());
|
||||
string name;
|
||||
float val;
|
||||
while(list_file >> name >> val) {
|
||||
Mat img = imread(path + name);
|
||||
images.push_back(img);
|
||||
times.push_back(1 / val);
|
||||
}
|
||||
list_file.close();
|
||||
}
|
||||
void loadExposureSeq(String, vector<Mat>&, vector<float>&);
|
||||
|
||||
int main(int argc, char**argv)
|
||||
int main(int, char**argv)
|
||||
{
|
||||
vector<Mat> images;
|
||||
vector<float> times;
|
||||
@ -49,3 +37,17 @@ int main(int argc, char**argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void loadExposureSeq(String path, vector<Mat>& images, vector<float>& times)
|
||||
{
|
||||
path = path + std::string("/");
|
||||
ifstream list_file((path + "list.txt").c_str());
|
||||
string name;
|
||||
float val;
|
||||
while(list_file >> name >> val) {
|
||||
Mat img = imread(path + name);
|
||||
images.push_back(img);
|
||||
times.push_back(1 / val);
|
||||
}
|
||||
list_file.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user