OpenCV Save a Mat as Binary (1-bit depth) TIFF
Asked Answered
S

1

3

Suppose we have a Mat after applying the OpenCv's Imgproc.adaptiveThreshold:

    Mat srcImage = ...;
    Mat binaryImage = new Mat();

    Imgproc.adaptiveThreshold(srcImage, binaryImage, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,
        Imgproc.THRESH_BINARY, THRESHOLD_BLOCK_SIZE, 10);

When I save the binaryImage using Highgui.imwrite:

boolean isOk = Highgui.imwrite("sample.tiff", binaryImage);

Everything is ok except that output TIFF is not actually a binary TIFF - it's a 8-bit depth image: enter image description here

What I'm trying to achieve is a similar to the below TIFF format with the 1-bit depth:

enter image description here

The question is how to do so with OpenCV?

Somerset answered 17/6, 2015 at 11:15 Comment(1)
This time I'm facing same issue with opencv.Azores
W
2

Only 8-bit (or 16-bit unsigned) single-channel or 3-channel images can be saved by imwrite.

Weldon answered 17/6, 2015 at 20:35 Comment(1)
How can we achieve this? How can we save 1-bit tiff image in opencv?Azores

© 2022 - 2024 — McMap. All rights reserved.