opencv彩色图像可视化实例
来源:互联网 发布:数据库的安全防护措施 编辑:程序博客网 时间:2024/04/29 03:48
输入:groundtruth 图像目录和程序分割结果目录
输出:差异图像,在每一幅图像中TP FP TN FN像素分别用4种颜色表示。
// // valueTest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <fstream>#include <cmath>#include "opencv2/core.hpp"#include <string>#include <string.h>#include "opencv2/opencv.hpp"#include <vector>#include "opencv2/imgproc.hpp"#include "opencv2/imgproc/types_c.h"#include <io.h>using namespace std;using namespace cv;bool get_filelist_from_dir(string path, vector<string>& files){long hFile = 0;struct _finddata_t fileinfo;files.clear();if ((hFile = _findfirst(path.c_str(), &fileinfo)) != -1){do{if (!(fileinfo.attrib&_A_SUBDIR))files.push_back(fileinfo.name);} while (_findnext(hFile, &fileinfo) == 0);_findclose(hFile);return true;}elsereturn false;}int main(){string in = "stares";string file1 = "../../视网膜血管分割0725/" + in + "/分割最终结果/";string ground_path = "../../视网膜血管分割0725/" + in + "/stare-groudtruth1/";string showcolor = "../../视网膜血管分割0725/" + in + "/color/";string search_path = file1 + "*.tif";string search_path_groundtruth = ground_path + "*.ppm";vector<string> file_list;vector<string> file_list_g;double avgAcc = 0, avgSe = 0, avgSp = 0, avgF = 0;if (!get_filelist_from_dir(search_path, file_list))cout << "open file error!" << endl;if (!get_filelist_from_dir(search_path_groundtruth, file_list_g))cout << "open file error!" << endl;double start = double(getTickCount());for (int a = 0; a < file_list.size(); a++){string image_path = file1 + file_list[a];Mat image = imread(image_path, IMREAD_GRAYSCALE);string image_g = ground_path + file_list_g[a];Mat groundtruth = imread(image_g, IMREAD_GRAYSCALE);Mat tmpColor = imread(image_g, IMREAD_COLOR);//tmpColor.convertTo(tmpColor,CV_64FC1);string c;ostringstream oss;oss.str("");oss << a + 1;c = oss.str();//计算准确率,召回率和误判率double k1 = 0.0, k2 = 0.0, k3 = 0.0, k4 = 0.0;for (int m2 = 0; m2 < image.rows; m2++){for (int n2 = 0; n2 < image.cols; n2++){if (image.at<uchar>(m2, n2) == 255 && groundtruth.at<uchar>(m2, n2) == 0){k1 += 1.0;//fptmpColor.at<Vec3b>(m2, n2)[0] = 255;tmpColor.at<Vec3b>(m2, n2)[1] = 0;tmpColor.at<Vec3b>(m2, n2)[2] = 0;}if (image.at<uchar>(m2, n2) == 255 && groundtruth.at<uchar>(m2, n2) == 255){k2 += 1.0;//tptmpColor.at<Vec3b>(m2, n2)[0] = 0;tmpColor.at<Vec3b>(m2, n2)[1] = 255;tmpColor.at<Vec3b>(m2, n2)[2] = 0;}if (image.at<uchar>(m2, n2) == 0 && groundtruth.at<uchar>(m2, n2) == 255){k3 += 1.0;//fntmpColor.at<Vec3b>(m2, n2)[0] = 0;tmpColor.at<Vec3b>(m2, n2)[1] = 0;tmpColor.at<Vec3b>(m2, n2)[2] = 255;}if (image.at<uchar>(m2, n2) == 0 && groundtruth.at<uchar>(m2, n2) == 0){k4 += 1.0;//tntmpColor.at<Vec3b>(m2, n2)[0] = 128;tmpColor.at<Vec3b>(m2, n2)[1] = 128;tmpColor.at<Vec3b>(m2, n2)[2] = 128;}}}string tmpImg = showcolor + c + ".tif"; imwrite(tmpImg,tmpColor);}return 0;}
0 0
- opencv彩色图像可视化实例
- opencv 彩色图像直方图
- opencv 彩色图像对比度增强
- opencv 彩色图像对比度增强
- opencv 彩色图像对比度增强
- opencv 彩色图像对比度增强
- Opencv彩色图像均衡问题
- opencv 彩色图像对比度增强
- opencv 彩色图像对比度增强
- opencv彩色图像通道分离
- openCV彩色图像转换为灰度图像
- opencv彩色图像与灰度图像叠加
- Opencv绘制灰度/彩色图像的直方图及直方图的均衡化实例及源代码
- opencv例程之彩色图像的分割
- opencv程序十:彩色图像均衡化
- OpenCV彩色图像转灰度图
- opencv中彩色图像通道分离、合成
- python opencv 提取彩色图像三通道
- 关于C51的IE(中断使能寄存器)的初级认识
- Java源码:ArrayList的实现原理
- 类文件结构
- Android如何判断时间是否在0到8点之间
- 【miscellaneous】GPRS本质论
- opencv彩色图像可视化实例
- android adb源码分析(2)
- 数组中出现次数超过一半的数字
- 冒泡排序
- 我的音乐收藏 http://www.xiami.com/u/45574524
- 使用 Gradle 与 Travis CI 进行简单持续集成 II
- javascript引用类型
- 2016年华为秋招机试题——2.字符串排序(200分)
- 使用文件来保存程序中的数据