Skip to content

TiffEncoder write support more depth type#21428

Merged
alalek merged 4 commits intoopencv:4.xfrom
Harvey-Huang:TIFF
Jan 31, 2022
Merged

TiffEncoder write support more depth type#21428
alalek merged 4 commits intoopencv:4.xfrom
Harvey-Huang:TIFF

Conversation

@Harvey-Huang
Copy link
Copy Markdown
Contributor

@Harvey-Huang Harvey-Huang commented Jan 12, 2022

Merge with extra: opencv/opencv_extra#955

Pull Request Readiness Checklist

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

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
opencv_extra=master

@mshabunin
Copy link
Copy Markdown
Contributor

Could you please add corresponding tests: https://github.com/opencv/opencv/blob/4.x/modules/imgcodecs/test/test_tiff.cpp ?

@Harvey-Huang
Copy link
Copy Markdown
Contributor Author

I don't know how to create a geotiff file, so I don't have a short type tif file(TIFFTAG_SAMPLEFORMAT is : SAMPLEFORMAT_INT), my testting file is download from https://download.osgeo.org/geotiff/samples/usgs/, file name is "i30dem.tif",.

@mshabunin
Copy link
Copy Markdown
Contributor

Maybe the test could just do imwrite and imread with synthetic Mat and check its contents afterwards?

@Harvey-Huang
Copy link
Copy Markdown
Contributor Author

I am updated testing code, and pull gray_8u.tif to opencv_extra repo.

TEST(Imgcodecs_Tiff, readWrite_unsigned)
{
const string root = cvtest::TS::ptr()->get_data_path();
const string filenameInput = root + "readwrite/gray_8u.tiff";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gray_8u.tiff

vs

gray_8u.tif

Please run tests locally before submitting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to run tests locally? are there any document I can study? Thank you very much!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8.Run testsuite locally:
1.get the required sample data by cloning https://github.com/opencv/opencv_extra (choose corresponding branch).
2.export OPENCV_TEST_DATA_PATH=<path_to_opencv_extra>/testdata.
3.execute each test binary from the build directory, e.g. ./bin/opencv_test_core.
got it!I will run it next time.


Mat matS8;
img.copyTo(matS8);
matS8.flags |= CV_8SC1; //hard code set type as CV_8SC1 for testing.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use convertTo() instead of hijacking of internal flags.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for update!

{
case CV_8U:
sample_format = SAMPLEFORMAT_UINT;
case CV_8S:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you for contribution 👍

@alalek alalek merged commit f4a7754 into opencv:4.x Jan 31, 2022
@alalek alalek mentioned this pull request Feb 22, 2022
@Harvey-Huang Harvey-Huang deleted the TIFF branch May 10, 2022 02:09
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
TiffEncoder write support more depth type

* TiffEncoder write support more depth type

* testing code

* update testing code

* add fallthrough
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants