在医院实际环境中,经常遇到有问题的患者,对于一些特殊的场景,比如骨折,肺结节,心脑血管问题
需要图像对比增强来更为清晰的显示病灶助于医生确诊,先看效果:
肺纹理增强:
肺结节增强:
血管对比增强:
骨骼对比增强:
根据参考资料:
MATLAB版本:
https://ww2.mathworks.cn/matlabcentral/fileexchange/24409-hessian-based-frangi-vesselness-filter
算法原理:
https://baike.baidu.com/item/%E9%BB%91%E5%A1%9E%E7%9F%A9%E9%98%B5/2248782?fr=aladdin
将其原理翻译写成C++类库,在C++中使用Opencv对于矩阵操作比较方便,导出dll后再由C#调用,
新建C++类库工程:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>
#include "MatBase64.h"
#include "frangi.h"
#include "ET.Functions.h"
using namespace std;
using namespace cv;
char* GetFrangiBase64Code(char* base64code, int SIGMA_START, int SIGMA_END, int SIGMA_STEP, float BETA_ONE, float BETA_TWO, bool BLACKWHITE){
//初始化矩阵参数
frangi2d_opts_t opts;
frangi2d_createopts(&opts, SIGMA_START, SIGMA_END, SIGMA_STEP, BETA_ONE, BETA_TWO, BLACKWHITE);
//处理传入的base64编码转为Mat对象
string imgcode =base64code;
string s_mat;
s_mat = base64Decode(imgcode.data(), imgcode.size());
vector<char> base64_img(s_mat.begin(), s_mat.end());
Mat input_img = cv::imdecode(Mat(base64_img), CV_LOAD_IMAGE_GRAYSCALE);
//进行frangi算法处理
Mat input_img_fl;
input_img.convertTo(input_img_fl, CV_32FC1);
Mat vesselness, scale, angles;
frangi2d(input_img_fl, vesselness, scale, angles, opts);
vector<uchar> buf;
imencode(".jpg", vesselness * 255, buf);
auto *enc_msg = reinterpret_cast<unsigned char*>(buf.data());
string encoded = base64Encode(enc_msg, buf.size());
//返回base64编码
char *result = new char[encoded.length() + 1];
for (int i = 0; i < encoded.length(); ++i)
{
result[i] = encoded[i];
}
result[encoded.length()] = '