Ai
1 Star 5 Fork 1

cubone/learnopencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
threshold.cpp 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
Satya Mallick 提交于 2015-04-07 14:19 +08:00 . Compatibility with OpenCV 3
/**
* OpenCV Threshold Example
*
* Copyright 2015 by Satya Mallick <spmallick@gmail.com>
*
**/
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
// Read image
Mat src = imread("threshold.png", IMREAD_GRAYSCALE);
Mat dst;
// Basic threhold example
threshold(src,dst,0, 255, THRESH_BINARY);
imwrite("opencv-threshold-example.jpg", dst);
// Thresholding with maxval set to 128
threshold(src, dst, 0, 128, THRESH_BINARY);
imwrite("opencv-thresh-binary-maxval.jpg", dst);
// Thresholding with threshold value set 127
threshold(src,dst,127,255, THRESH_BINARY);
imwrite("opencv-thresh-binary.jpg", dst);
// Thresholding using THRESH_BINARY_INV
threshold(src,dst,127,255, THRESH_BINARY_INV);
imwrite("opencv-thresh-binary-inv.jpg", dst);
// Thresholding using THRESH_TRUNC
threshold(src,dst,127,255, THRESH_TRUNC);
imwrite("opencv-thresh-trunc.jpg", dst);
// Thresholding using THRESH_TOZERO
threshold(src,dst,127,255, THRESH_TOZERO);
imwrite("opencv-thresh-tozero.jpg", dst);
// Thresholding using THRESH_TOZERO_INV
threshold(src,dst,127,255, THRESH_TOZERO_INV);
imwrite("opencv-thresh-to-zero-inv.jpg", dst);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cubone/learnopencv.git
git@gitee.com:cubone/learnopencv.git
cubone
learnopencv
learnopencv
master

搜索帮助