【20160924】GOCVHelper 图像增强部分(1)
图像增强是图像处理的第一步。这里集成了一些实际使用过程中有用的函数。 //读取灰度或彩色图片到灰度 Matimread2gray(stringpath){ Matsrc=imread(path); MatsrcClone=src.clone(); if(CV_8UC3==srcClone.type()) cvtColor(srcClone,srcClone,CV_BGR2GRAY); returnsrcClone; } 算法核心在于判断读入图片的通道数,如果是灰度图片则保持;如果是彩色图片则转换为灰度图片。通过这样一个函数,就能够直接获得灰度图片。 //带有上下限的threshold Matthreshold2(Matsrc,intminvalue,intmaxvalue){ Matthresh1; Matthresh2; Matdst; threshold(src,thresh1,minvalue,255,THRESH_BINARY); threshold(src,thresh2,maxvalue,255,THRESH_BINARY_INV); dst=thresh1&...
















