opencv/samples/cpp
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
..
example_cmake Fix configuring with CMake version 4 2025-04-02 13:45:08 -07:00
tutorial_code Merge pull request #27396 from abhishek-gola:hdr_bug_fix 2025-06-05 09:02:58 +03:00
3calibration.cpp Merge pull request #23108 from crackwitz:issue-23107 2023-01-09 09:55:31 +00:00
application_trace.cpp Update Samples 2019-09-05 01:10:51 +03:00
aruco_dict_utils.cpp Merge pull request #23018 from stopmosk:move-aruco-tutorial 2024-02-26 14:57:46 +03:00
asift.cpp Merge pull request #17907 from Yosshi999:gsoc_asift-py2cpp 2020-08-03 14:11:55 +00:00
audio_spectrogram.cpp Merge pull request #20934 from SinM9:spectrogram_samples 2021-12-14 17:33:26 +00:00
barcode.cpp Merge pull request #23666 from mshabunin:barcode-move 2023-06-14 22:21:38 +03:00
bgfg_segm.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
calibration.cpp Merge pull request #23486 from vovka643:4.x_calibration_with_aruco 2023-04-26 12:13:16 +03:00
camshiftdemo.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
cloning_demo.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
cloning_gui.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
CMakeLists.txt Revert "suppress warning on GCC 7 and later" 2022-08-07 15:43:10 +03:00
connected_components.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
contours2.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
convexhull.cpp Update convexhull.cpp 2021-09-11 23:58:14 +03:00
cout_mat.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
create_mask.cpp Update samples 2020-07-23 20:09:37 +03:00
dbt_face_detection.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
delaunay2.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
demhist.cpp Update Samples 2019-09-05 01:10:51 +03:00
detect_blob.cpp fix 4.x links 2021-12-22 13:24:30 +00:00
detect_mser.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2020-03-04 20:49:09 +00:00
dft.cpp Update Samples 2019-09-05 01:10:51 +03:00
digits_lenet.cpp add OpenCV sample for digit and text recongnition, and provide multiple OCR models. 2020-08-22 01:02:13 +08:00
digits_svm.cpp Add namespace specifier for format() 2021-04-21 14:08:52 +08:00
dis_opticalflow.cpp Update samples 2019-09-20 18:03:26 +03:00
distrans.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
drawing.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
edge.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
ela.cpp Update samples 2019-09-20 18:03:26 +03:00
em.cpp Updated ml module interfaces and documentation 2015-02-17 11:46:14 +03:00
epipolar_lines.cpp Merge pull request #17683 from ivashmak:homography 2020-08-14 22:42:26 +00:00
essential_mat_reconstr.cpp Update essential_mat_reconstr.cpp 2021-01-18 23:56:34 +08:00
facedetect.cpp Merge pull request #23108 from crackwitz:issue-23107 2023-01-09 09:55:31 +00:00
facial_features.cpp fix 4.x links 2021-12-22 13:24:30 +00:00
falsecolor.cpp Fix trackbar in falsecolor cpp sample 2021-11-06 10:11:58 +00:00
fback.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
ffilldemo.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
fitellipse.cpp Change article for fitEllipseDirect function 2025-01-07 22:24:48 +03:00
flann_search_dataset.cpp Merge pull request #17643 from pemmanuelviel:pev--new-flann-demo 2020-08-10 13:26:40 +00:00
grabcut.cpp Updated grabcut example to show the background in a transparant way 2021-07-14 22:02:27 +02:00
image_alignment.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
imagelist_creator.cpp update cpp samples and tutorials 2016-06-26 20:55:00 +03:00
imagelist_reader.cpp Merge pull request #13188 from alalek:samples_rename 2018-11-17 00:35:05 +03:00
imgcodecs_jpeg.cpp build: fix warnings 2022-07-02 00:56:10 +03:00
inpaint.cpp Update Samples 2019-09-05 01:10:51 +03:00
intelligent_scissors.cpp Merge pull request #16853 from SimpleVlad:note 2020-03-19 21:39:54 +00:00
intersectExample.cpp Update samples 2020-07-23 20:09:37 +03:00
kalman.cpp Merge pull request #20564 from AleksandrPanov:update_kalman_sample 2021-08-20 10:57:05 +00:00
kmeans.cpp Merge pull request #10258 from savuor:fix/kmeans_channels 2017-12-15 21:48:48 +03:00
laplace.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
letter_recog.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
lkdemo.cpp Merge pull request #9618 from vipinanand4:goodFeaturesToTrack_added_gradiantSize 2017-09-22 14:04:43 +00:00
logistic_regression.cpp ml: use OpenCV license header for logistic regression 2021-03-17 20:29:52 +00:00
lsd_lines.cpp restore LSD 2021-10-01 16:23:16 +03:00
mask_tmpl.cpp Backport C-API cleanup (imgproc) from 5.x 2023-01-16 23:29:50 +03:00
matchmethod_orb_akaze_brisk.cpp fix 4.x links 2021-12-22 13:24:30 +00:00
minarea.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
morphology2.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
neural_network.cpp Issue 6780 2016-07-07 09:29:41 +02:00
npr_demo.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
opencv_version.cpp Minor refactoring in several C++ samples: 2018-03-06 14:23:20 +03:00
pca.cpp Merge pull request #23108 from crackwitz:issue-23107 2023-01-09 09:55:31 +00:00
peopledetect.cpp Update Samples 2019-09-05 01:10:51 +03:00
phase_corr.cpp update samples: waitKey() usage 2016-12-15 15:39:47 +03:00
points_classifier.cpp samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
polar_transforms.cpp Update Samples 2019-09-05 01:10:51 +03:00
qrcode.cpp added graphicalCodeDetector, remove QRCodeDetectorBase 2023-06-08 14:50:58 +03:00
segment_objects.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
select3dobj.cpp Merge pull request #22149 from seanm:sprintf 2022-06-25 06:48:22 +03:00
simd_basic.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
smiledetect.cpp Update Samples 2019-09-05 01:10:51 +03:00
squares.cpp Fix squares sample failure when a single file passed 2021-04-28 09:36:04 +03:00
stereo_calib.cpp added aruco pattern into stereo_calibration.cpp 2023-05-16 12:22:03 +03:00
stereo_match.cpp Update the stereo sample: 2020-08-20 12:20:25 +02:00
stitching_detailed.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2020-04-24 19:02:39 +00:00
stitching.cpp Changed sample code, fixes #18807 2020-11-14 23:29:51 +02:00
text_skewness_correction.cpp Added tutorial for text skewness correction in C++ and Python. 2020-01-23 08:24:39 +03:00
train_HOG.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
train_svmsgd.cpp Fix some clang 14 warnings 2023-02-07 01:19:00 +03:00
travelsalesman.cpp Fixed compilation warnings in samples: 2018-02-12 18:42:36 +03:00
tree_engine.cpp using argv[0] represent binary executable files' name in help() function 2020-02-28 20:36:56 +08:00
videocapture_audio_combination.cpp Merge pull request #19721 from MaximMilashchenko:Audio 2021-10-20 16:18:24 +03:00
videocapture_audio.cpp Merge pull request #19721 from MaximMilashchenko:Audio 2021-10-20 16:18:24 +03:00
videocapture_basic.cpp Update videocapture_basic.cpp 2020-04-24 11:42:45 +03:00
videocapture_camera.cpp samples: videocapture_camera use VideoCapture with 0 index 2018-07-03 15:44:53 +03:00
videocapture_gphoto2_autofocus.cpp FIx misc. source and comment typos 2019-08-15 13:09:52 +03:00
videocapture_gstreamer_pipeline.cpp videoio(doc): add 'videoio_hwaccel' group, fix typos 2021-03-07 04:47:22 +00:00
videocapture_image_sequence.cpp Merge pull request #13188 from alalek:samples_rename 2018-11-17 00:35:05 +03:00
videocapture_microphone.cpp Merge pull request #19721 from MaximMilashchenko:Audio 2021-10-20 16:18:24 +03:00
videocapture_obsensor.cpp Merge pull request #24877 from zzuliys:feature/mac 2024-03-29 11:23:41 +03:00
videocapture_openni.cpp Add tutorial on how to use Orbbec Astra 3D cameras 2020-11-19 13:31:22 +03:00
videocapture_realsense.cpp New example for realsense 2021-12-16 15:07:53 -03:00
videocapture_starter.cpp Merge pull request #22149 from seanm:sprintf 2022-06-25 06:48:22 +03:00
videowriter_basic.cpp samples: avoid using of legacy C-like API 2018-03-26 13:42:35 +03:00
warpPerspective_demo.cpp Fix some clang 14 warnings 2023-02-07 01:19:00 +03:00
watershed.cpp Merge pull request #23108 from crackwitz:issue-23107 2023-01-09 09:55:31 +00:00