opencv/samples/cpp/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
..
calib3d Merge pull request #23018 from stopmosk:move-aruco-tutorial 2024-02-26 14:57:46 +03:00
core Merge pull request #26260 from sturkmen72:upd_doc_4_x 2024-10-09 09:09:51 +03:00
features2D Add more references. Update missing references with webarchive. Use mathbf for matrices. Check that the determinant of the rotation matrix is not negative (reflection), and correct it if it is the case. 2022-06-19 01:27:32 +02:00
gapi Merge pull request #21157 from alexgiving:atrutnev/move_resize 2021-12-29 15:13:43 +00:00
gpu Fix configuring with CMake version 4 2025-04-02 13:45:08 -07:00
HighGUI Merge pull request #26524 from MurtazaSaherwala:DocumentationUpdation 2024-12-09 16:23:07 +03:00
Histograms_Matching Merge pull request #23442 from LaurentBerger:tuto_findFile 2023-04-06 13:02:00 +03:00
imgcodecs Merge pull request #25608 from sturkmen72:animated_webp_support 2024-12-20 13:06:28 +03:00
ImgProc Merge pull request #23442 from LaurentBerger:tuto_findFile 2023-04-06 13:02:00 +03:00
ImgTrans Merge pull request #26815 from shyama7004:fix-deprecation 2025-01-22 13:53:59 +03:00
introduction Merge pull request #16889 from mehlukas:3.4-consolidateImshow 2020-04-07 14:14:51 +00:00
ml Update Samples 2019-09-05 01:10:51 +03:00
objectDetection Merge pull request #26815 from shyama7004:fix-deprecation 2025-01-22 13:53:59 +03:00
photo Merge pull request #27396 from abhishek-gola:hdr_bug_fix 2025-06-05 09:02:58 +03:00
ShapeDescriptors Update Samples 2019-09-05 01:10:51 +03:00
snippets Enhance cv::TickMeter to be able to get the last ellapsed time 2024-09-28 12:24:36 +02:00
TrackingMotion build: eliminate build warnings 2021-08-28 17:11:26 +00:00
video Update optical_flow.cpp 2025-02-11 13:30:48 +03:00
videoio Merge pull request #25813 from kaingwade:orbbec-astra 2024-07-01 10:55:35 +03:00
xfeatures2D Update Samples 2019-09-05 01:10:51 +03:00