Opencv3.1 MultiBandBlender源码分析

本文深入分析了OpenCV3.1中的MultiBandBlender,详细介绍了其工作流程,包括确定ROI区域大小、设置band数量、调整区域尺寸以满足整数倍要求、创建目标图像和掩模、初始化拉普拉斯金字塔和权重金字塔,并对每一层的处理进行了详尽的阐述。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

void MultiBandBlender::prepare(Rect dst_roi)
{
    dst_roi_final_ = dst_roi;

    // Crop unnecessary bands
    double max_len = static_cast<double>(std::max(dst_roi.width, dst_roi.height));
    num_bands_ = std::min(actual_num_bands_, static_cast<int>(ceil(std::log(max_len) / std::log(2.0))));

    // Add border to the final image, to ensure sizes are divided by (1 << num_bands_)
    dst_roi.width += ((1 << num_bands_) - dst_roi.width % (1 << num_bands_)) % (1 << num_bands_);
    dst_roi.height += ((1 << num_bands_) - dst_roi.height % (1 << num_bands_)) % (1 << num_bands_);

    Blender::prepare(dst_roi);

    dst_pyr_laplace_.resize(num_bands_ + 1);
    dst_pyr_laplace_[0] = dst_;

    dst_band_weights_.resize(num_bands_ + 1);
    dst_band_weights_[0].create(dst_roi.size(), weight_type_);
    dst_band_weights_[0].setTo(0);

    for (int i = 1; i <= num_bands_; ++i)
    {
        dst_pyr_laplace_[i].create((dst_pyr_laplace_[i - 1].rows + 1) / 2,
                                   (dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3);
        dst_band_weights_[i].create((dst_band_weights_[i - 1].rows + 1) / 2,
                                    (dst_band_weights_[i - 1].cols + 1) / 2, weight_type_);
        dst_pyr_laplace_[i].setTo(Scalar::all(0));
        dst_band_weights_[i].setTo(0);
    }
}


1. 确定最终ROI区域的大小
2. 确定最终的要用多少个band
3. 对感兴趣区域的宽和高进行调整,确保能被 1 << num_bands_ 整除
4. 调用Blender类下的prepare方法,创建dst_,dst_mask和把 dst_roi赋值给Blender下的成员对象dst_roi_
5. 将ROI区域赋值给dst_pyr_laplace_的第0层,拉普拉斯金字塔总共num_bands_+1 层,相应的band权重的金字塔也为 num_bands_+1 层,band权重金字塔第0层的清零
6. 金字塔第1层的宽和高是第0层的一半,同理类推,第2层是1层的一半,第3层是2层的一半… ,最终权重金字塔的每一层都清零


分析
void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值