测试 focus stacking

https://github.com/PetteriAimonen/focus-stack
https://github.com/Biomedical-Imaging-Group/EDF-Extended-Depth-of-Field

Helicon Focus 软件 3d重建效果

focus-stack 输出的融合图像

focus-stack 输出的3d渲染图像

仅修改Task_FocusMeasure 后的3d渲染图像

soebel 改laplacian

cpp 复制代码
void Task_FocusMeasure::task()
{
    // Algorithm is based on Tenengrad focus measure from
    // 'Autofocusing Algorithm Selection in Computer Microscopy' by Sun et Al.

    const cv::Mat &input = m_input->img();
    int rows = input.rows;
    int cols = input.cols;
    m_valid_area = m_input->valid_area();

    // Calculate squared gradient magnitude by calculating
    // horizontal and vertical Sobel operator.
    cv::Mat sobel(rows, cols, CV_32F);
    cv::Mat magnitude(rows, cols, CV_32F, cv::Scalar(0));
    cv::Sobel(input, sobel, CV_32FC1, 1, 0);
    cv::accumulateSquare(sobel, magnitude);
    cv::Sobel(input, sobel, CV_32FC1, 0, 1);
    cv::accumulateSquare(sobel, magnitude);
    sobel.release();

    
    //cv::Mat laplacian;
    //cv::Laplacian(input, laplacian, CV_32F);
    //cv::Mat magnitude(rows, cols, CV_32F, cv::Scalar(0));
    //cv::multiply(laplacian, laplacian, magnitude); // squared Laplacian = variance proxy
    //cv::Mat temp;
    //cv::GaussianBlur(magnitude, temp, cv::Size(), 1, 1, cv::BORDER_REFLECT);
   
    ////cv::bilateralFilter(magnitude, temp, 5, 500, 5);
    //cv::medianBlur(temp, temp, 3);
    //magnitude = std::move(temp); 
    m_input.reset();

    magnitude.setTo(0, magnitude < m_threshold);

    if (m_radius > 0)
    {
        int blurwindow = (int)(m_radius * 4) + 1;
        cv::GaussianBlur(magnitude, magnitude, cv::Size(blurwindow, blurwindow), m_radius, m_radius, cv::BORDER_REFLECT);
    }

    cv::sqrt(magnitude, m_result);
}
相关推荐
weixin_433417673 小时前
Canny边缘检测算法原理与实现
python·opencv·算法
澜莲花6 小时前
python图色之opencv基础---验证码实战
开发语言·python·opencv
only-lucky9 小时前
Python版本OpenCV
开发语言·python·opencv
AI街潜水的八角11 小时前
基于Opencv的二维码识别与创建
人工智能·opencv·计算机视觉
编码小哥11 小时前
OpenCV GrabCut前景提取技术详解
人工智能·opencv·计算机视觉
意趣新12 小时前
OpenCV 中摄像头视频采集 + 实时显示 + 视频保存
python·opencv·计算机视觉
dazzle14 小时前
计算机视觉处理(OpenCV基础教学(十三):图像水印添加技术详解)
人工智能·opencv·计算机视觉
only-lucky1 天前
OpenCV(第一章)
人工智能·opencv·计算机视觉
AndrewHZ1 天前
【图像处理基石】如何高质量地生成一张庆祝元旦的图片?
图像处理·人工智能·opencv·算法·计算机视觉·生成式模型·genai