opencv/samples/python/tutorial_code
Abhishek Gola aef6ae4872
Merge pull request #27396 from abhishek-gola:hdr_bug_fix
Fix NaNs in HDR Triangle Weights and Tonemapping and Update LDR Ground Truth in tutorial #27396

The PR closes #27392 

Updated the triangle weights to use a small epsilon value instead of zero to prevent NaN issues in HDR processing.
Also fixed a float-to-double division issue by explicitly casting double values to float, which was previously producing garbage values and leading to NaNs in tonemapping.

The current LDR ground truth image used in the tutorial [ldr.png](https://github.com/opencv/opencv/blob/4.x/doc/tutorials/others/images/ldr.png) was originally generated using TonemapDurand (check this commit 833f8d16fa), which was moved to opencv_contrib a long time ago in this commit: 742f22c09b. However, the current Tonemap implementation in OpenCV main only performs normalization and gamma correction, which produces noticeably different results. This PR updates the LDR grouth truth image in tutorial with the result of TonemapDrago, and tutorials to use TonemapDrago as Tonemap gives a darker image.

Tonemap output:
![ldr2](https://github.com/user-attachments/assets/e4f0cb97-ee4f-47b9-8962-2020ff211fd5)

TonemapDrago output:
![ldr](https://github.com/user-attachments/assets/4a898101-22bd-49e5-8db0-9e1062974ba3)


### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2025-06-05 09:02:58 +03:00
..
core Merge pull request #26260 from sturkmen72:upd_doc_4_x 2024-10-09 09:09:51 +03:00
dnn/dnn_conversion Merge pull request #17801 from LupusSanctus:am/pytorch_tf_segm 2021-04-01 20:42:08 +00:00
features2D Merge pull request #16366 from themechanicalcoder:features2D-tutorial-python 2020-02-01 20:20:00 +03:00
highgui/trackbar samples: use findFile() in "python" 2018-11-16 18:08:22 +00:00
Histograms_Matching Update python samples 2021-02-21 23:02:16 +03:00
imgcodecs Merge pull request #25608 from sturkmen72:animated_webp_support 2024-12-20 13:06:28 +03:00
imgProc Update match_template.py to fix doc bug 2025-05-12 17:06:24 +03:00
ImgTrans Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-02-12 21:34:49 +00:00
introduction Merge pull request #16889 from mehlukas:3.4-consolidateImshow 2020-04-07 14:14:51 +00:00
ml Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-02-27 17:41:57 +00:00
objectDetection/cascade_classifier FIx misc. source and comment typos 2019-08-15 13:09:52 +03:00
photo/hdr_imaging Merge pull request #27396 from abhishek-gola:hdr_bug_fix 2025-06-05 09:02:58 +03:00
ShapeDescriptors Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2020-04-21 21:32:51 +00:00
TrackingMotion Update python samples 2021-02-21 23:02:16 +03:00
video Merge pull request #21224 from UncleLLD:fix-cvtColor-error 2021-12-09 19:11:05 +00:00
videoio Update python samples 2021-02-21 23:02:16 +03:00