##################
Denoising an Image
##################

Well, this might be one of the shortest tutorials in HOOPS Luminate: we use the scene that was setup in :doc:`/tutorials/workflows/wf_rendering/wf_using_skylight_portals`. Then, we turn on the :doc:`/book/subjects/bk_re/bk_re_srd/bk_re_rt/bk_re_adaptive_sampling` and turn the :doc:`/book/subjects/bk_re/bk_re_denoising` on using the code sequence below:


.. code:: cpp 

    // Set the HM sampler with adaptive ray-tracing:
    RC_TEST( iresopt->SetOptionValue( RED::OPTIONS_SAMPLER, 1, iresmgr->GetState() ) );
    RC_TEST( icamopt->SetOptionValue( RED::OPTIONS_RAY_ADAPTIVE_SAMPLING_THRESHOLD, 0.1, iresmgr->GetState() ) );
    RC_TEST( icamopt->SetOptionValue( RED::OPTIONS_RAY_GLOSSY_SAMPLING_RATE, 16, iresmgr->GetState() ) );
    RC_TEST( icamopt->SetOptionValue( RED::OPTIONS_RAY_LIGHTS_SAMPLING_RATE, 16, iresmgr->GetState() ) );
    RC_TEST( ivrl->SetSoftAntiAlias( 8, iresmgr->GetState() ) );

    // Turn on the denoiser. Use a mild denoiser setup:
    RC_TEST( icamopt->SetOptionValue( RED::OPTIONS_RAY_ENABLE_DENOISER, true, iresmgr->GetState() ) );
    RC_TEST( icamopt->SetOptionValue( RED::OPTIONS_RAY_DENOISER_STRENGTH, 1.0, iresmgr->GetState() ) );
    RC_TEST( icamopt->SetOptionValue( RED::OPTIONS_RAY_DENOISER_RADIUS, 5, iresmgr->GetState() ) );

And we get the results below:

.. figure:: wf_denoising_an_image_1.png
  :align: center

  **Image prior to the denoiser being applied**

.. figure:: wf_denoising_an_image_2.png
  :align: center
  
  **Image after the denoiser is applied**

Here, since our noise is quite homogeneous thanks to the adaptive sampling, we don't need a large denoiser radius. See the doc :doc:`/book/subjects/bk_re/bk_re_denoising` in the section **Using the Denoiser** for more explanations on the denoiser parameters.

While the denoiser blurs some features such as shadows falloffs, mirrored reflections, it remains interesting as it offers a way to quickly get rid of any noise in an image.

