7 FileStorage fs(
"statics/params.xml", FileStorage::READ);
10 cout <<
"Open file failed" << endl;
12 FileNode node = fs[
"image_preprocessor_threshod"];
14 for(
unsigned int i = 0; i < 3; i++)
16 cout << int(node[2*i]) << endl;
28 cvtColor(srcImage, dstImage, CV_BGR2HSV);
31 split(dstImage, hsvImages);
39 Mat dilateKernel = getStructuringElement(MORPH_RECT, Size(15, 15));
40 Mat closeKernel = getStructuringElement(MORPH_RECT, Size(3, 3));
44 dilate(hsvImages[0], hsvImages[0], dilateKernel);
50 bitwise_and(hsvImages[0], hsvImages[2], dstImage);
52 morphologyEx(dstImage, dstImage, MORPH_CLOSE, closeKernel);
55 imshow(
"hImage", hsvImages[0]);
56 imshow(
"SImage", hsvImages[1]);
57 imshow(
"VImage", hsvImages[2]);
60 imshow(
"result", dstImage);
78 threshold(srcImage, result, static_cast<double>(
thresholds[channel][0]), 0, THRESH_TOZERO);
79 threshold(result, result, static_cast<double>(
thresholds[channel][1]), 0, THRESH_TOZERO_INV);
Mat rangeThreshold(const Mat &srcImage, const int &channel)
用threshold函数实现区间图像提取
int getThreshod(int channel, int minOrMax) const
获取指定通道最大值或者最小值
Mat preprocess(const Mat &srcImage)
对读取到的图片预处理
vector< int > thresholds[3]
存储三通道过滤时,rgb的下上限值
void setThreshod(int channel, int minOrMax, int value)
设置预处理图像阈值
HLL Computer Vision Code namepace.