OpenCV将Mat保存为二进制(1位深度)TIFF [英] OpenCV Save a Mat as Binary (1-bit depth) TIFF

查看:1302
本文介绍了OpenCV将Mat保存为二进制(1位深度)TIFF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设应用OpenCv的Imgproc.adaptiveThreshold后有一个Mat:

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);

当我使用Highgui.imwrite保存binaryImage时:

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

一切正常,除了输出TIFF实际上不是二进制TIFF-它是一个8位深度的图像:

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

我要实现的目标与下面的TIFF格式类似,但深度为1位:

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

问题是如何使用OpenCV?

推荐答案

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆