Adding possibility to select the compression type for the OpenEXR format#19295
Adding possibility to select the compression type for the OpenEXR format#19295hallonterror wants to merge 3 commits intoopencv:masterfrom
Conversation
…mat. There are compression modes other than the default that are more suited for certain data. Mainly grainy/noisy data.
|
@hallonterror Thanks for the useful option. Couple of proposals for the solution:
|
| CV_IMWRITE_PNG_STRATEGY_FIXED =4, | ||
| CV_IMWRITE_PXM_BINARY =32, | ||
| CV_IMWRITE_EXR_TYPE = 48, | ||
| CV_IMWRITE_EXR_COMPRESSION = 49, |
There was a problem hiding this comment.
Legacy C files should not be touched anymore.
Please remove this change.
| header.compression() = DWAB_COMPRESSION; | ||
| break; | ||
| default: | ||
| throw std::runtime_error("IMWRITE_EXR_COMPRESSION is invalid or not supported"); |
There was a problem hiding this comment.
Should this be done although the CV_IMWRITE_EXR_TYPE throws? See line 592.
Reverting change to legacy/constants_c.h.
I know of the test data in opencv_extra. I think it should be sufficient to use one of the already existing image files (like it is in the added unit test (modules/imgcodecs/test/test_exr.impl.hpp), even though it wont show a compression advantage on those files. For the second point you are absolutely right. I did verify that the parameter had effect exactly this way, by checking that the file size was not the same as the previously existing unit test without the flag set. It's of course reasonable to add this as a check in the test suite. I will look into that! |
Adding size check that ensures that the selection of PIZ compression has an effect on file size. For this particular file it gets larger. For other suitable image content the file should be smaller.
| ASSERT_EQ(CV_32FC1,img.type()); | ||
|
|
||
| ASSERT_TRUE(cv::imwrite(filenameOutput, img)); | ||
| ASSERT_EQ(getFileSize(filenameOutput), 396); |
There was a problem hiding this comment.
Please add comment why you check file size here. It's important for test, but not obvious for other contributors.
| ASSERT_EQ(CV_32FC1, img.type()); | ||
|
|
||
| ASSERT_TRUE(cv::imwrite(filenameOutput, img, params)); | ||
| ASSERT_EQ(getFileSize(filenameOutput), 849); |
There was a problem hiding this comment.
The same for file size here.
| header.compression() = DWAB_COMPRESSION; | ||
| break; | ||
| default: | ||
| throw std::runtime_error("IMWRITE_EXR_COMPRESSION is invalid or not supported"); |
|
@hallonterror Please take a look on CI status. BuildBot reports build issue: |
|
@hallonterror Friendly reminder. |
|
@hallonterror Do you have a chance to finish the patch? |
|
@hallonterror Friendly reminder. |
|
@hallonterror Unfortunatelly I cannot push changes to you PR branch as you do it in master. I cherry picked the commits and created new PR with code review fixes: #19540 |
There are compression modes other than the default that are more suited for certain data. Mainly grainy/noisy data.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.