/// 多尺度图像增强
/// </summary>
/// <param name="DestPrj"></param>
/// <param name="w"></param>
/// <param name="w1"></param>
/// <param name="w2"></param>
/// <param name="w3"></param>
/// <param name="w4"></param>
void multiScaleSharpen(DCMRTImage* DestPrj, float w, float w1, float w2, float w3)
{
unsigned short* imageData = DestPrj->getImageData();
const RVector2I& sizeImag = DestPrj->getSize();
cv::Mat SrcImg(sizeImag[1], sizeImag[0], CV_16UC1, imageData);
////降噪
cv::Mat Src;
fastNlMeansDenoising(SrcImg, Src, { 50.0f }, 7, 21, cv::NORM_L1);//原有50降噪效果好,但是速度太慢
int Radius = 15;
float sigma1 = 1.0;
float sigma2 = 2.0;
float sigma3 = 4.0;
int N1 = 1;
int N2 = 2;
int N3 = 4;
cv::Mat B1, B2, B3;
pragma omp sections //第1个sections
{
pragma omp section
{
cv::GaussianBlur(Src, B1, cv::Size(Radius, Radius), 1.0, 1.0);
}
pragma omp section
{
cv::GaussianBlur(Src, B2, cv::Size(Radius * 2 - 1, Radius * 2 - 1), 2.0, 2.0);
}
pragma omp section
{
cv::GaussianBlur(Src, B3, cv::Size(Radius * 4 - 1, Radius * 4 - 1), 4.0, 4.0);
}
}
//边缘图像
cv::Mat D1, D2, D3;
pragma omp sections //第1个sections
{
pragma omp section
{
D1 = Src - B1;
}
pragma omp section
{
D2 = B1 - B2;
}
pragma omp section
{
D3 = B2 - B3;
}
}
//图像增强
cv::Mat dest = cv::Mat::zeros(Src.size(), Src.type());
pragma omp parallel for
for (int i = 0; i < Src.rows; i++)//行
{
int sign = 0;
for (size_t j = 0; j < Src.cols; j++)//列
{
if (D1.at<unsigned short>(i, j) > 0)
{
sign = 1;
}
else
{
sign = -1;
}
dest.at<unsigned short>(i, j) = cv::saturate_cast<ushort>((1 - w1 * sign) * D1.at<unsigned short>(i, j) + w2 * D2.at<unsigned short>(i, j) + w3 * D3.at<unsigned short>(i, j) + w * Src.at<unsigned short>(i, j));
}
}
memcpy(imageData, dest.data, sizeof(unsigned short) * dest.rows * dest.cols);
}
网友评论