当前位置: 首页 > news >正文

c++ opencv 复现Fiji 配对拼接算法中的加权融合

复现Fiji Is Just ->Plugins->Stitching->Pairewise stitching(默认参数)

未融合

fiji的效果

复现的效果

右下角效果不太理想

参考:插件源码+论文

Globally optimal stitching of tiled 3D microscopic image acquisitions

double computeWeight(const cv::Point& location,const  cv::Size& imgeSize, const cv::Size2d & imgAreaBlend)
{double minDistance = 1;int distance =max(1, min(location.x + 1, imgeSize.width - location.x ));if (distance < imgAreaBlend.width)minDistance *= distance / imgAreaBlend.width;distance = max(1, min(location.y + 1, imgeSize.height - location.y));if (distance < imgAreaBlend.height)minDistance *= distance / imgAreaBlend.height;if (minDistance == 1)return minDistance;else if (minDistance <= 0)return 0.0000001;elsereturn (cos((1.0 - minDistance) * CV_PI) + 1)*0.5;
}
void weightBlend(cv::Mat& blendedImg, const cv::Mat& leftImg, const cv::Mat& rightImg, cv::Point offset, double percentScaling)
{cv::Rect blendedImgRect;cv::Rect refLeftRect = cv::Rect(0, 0, leftImg.cols, leftImg.rows);cv::Rect refRightRect = cv::Rect(offset.x, offset.y, rightImg.cols, rightImg.rows);blendedImgRect = refLeftRect | refRightRect;blendedImg= Mat(blendedImgRect.size(), leftImg.type(),cv::Scalar::all(0));Point locationLeft, locationRight;Size leftImgSize = leftImg.size();Size rightImgSize = rightImg.size();double percentScalingHalf = percentScaling * 0.5f;cv::Size2d leftImgAreaBlend(round(percentScalingHalf * leftImgSize.width), round(percentScalingHalf * leftImgSize.height));cv::Size2d rightImgAreaBlend(round(percentScalingHalf * rightImgSize.width), round(percentScalingHalf * rightImgSize.height));double weight, weightSum, valueSum;bool outBoundLeft, outBoundRight;cv::Mat noblendedImg = blendedImg.clone();leftImg.copyTo(noblendedImg(refLeftRect - blendedImgRect.tl()));rightImg.copyTo(noblendedImg(refRightRect - blendedImgRect.tl()));for(int r=0;r< blendedImg.rows;++r){for (int c = 0; c < blendedImg.cols; ++c){locationLeft.x = c + blendedImgRect.x - refLeftRect.x;locationLeft.y = r + blendedImgRect.y - refLeftRect.y;outBoundLeft = locationLeft.x < 0 || locationLeft.x >= leftImg.cols ||locationLeft.y < 0 || locationLeft.y >= leftImg.rows;locationRight.x = c + blendedImgRect.x - refRightRect.x;locationRight.y = r + blendedImgRect.y - refRightRect.y;outBoundRight = locationRight.x < 0 || locationRight.x >= rightImg.cols ||locationRight.y < 0 || locationRight.y >= rightImg.rows;if (outBoundLeft&& outBoundRight){continue;}weightSum = 0;valueSum = 0;if (!outBoundLeft){weight = max(0.00001, computeWeight(locationLeft, leftImgSize, leftImgAreaBlend));weightSum += weight;valueSum += leftImg.at<uchar>(locationLeft) * weight;}if (!outBoundRight){weight = max(0.00001, computeWeight(locationRight, rightImgSize, rightImgAreaBlend));weightSum += weight;valueSum += rightImg.at<uchar>(locationRight) * weight;}blendedImg.at<uchar>(r, c) = cv::saturate_cast<uchar>(valueSum / weightSum);}}
}


 

 

http://www.dtcms.com/a/418410.html

相关文章:

  • 中秋国庆双节餐饮零售破局!Deepoc 具身模型外拓板打造 “假日智能运营新范式
  • 瑞安网站建设电话百度商桥接入网站
  • 嵌入式硬件——I.MX6ULL EPIT(增强型周期中断定时器)
  • 降低测试成本缩短测试周期 | 车辆OBD数据采集方案
  • 一级消防工程师考试时间新闻类网站怎么做seo
  • window显示驱动开发—确定显示适配器上的 VidPN 支持
  • Kafka05-入门-尚硅谷
  • Visual Studio 2022
  • 【不背八股】19.GPT-2:不再微调,聚焦零样本
  • 5、焊接质量检验及缺陷分析
  • 【AI】大模型的分析力横评:一次“伪异步”排查后的真实思考
  • 养老院服务质量建设专项网站广州seo关键词优化外包
  • 第一章 假设三:走势包含无序运动状态(混沌现象)和有序运动状态(下跌或上涨)
  • ElementUI-Table 表格实现行拖拽
  • Logit论文阅读
  • 网站cms建设wordpress模仿app启动广告屏弹窗
  • 21. 一个像素对应多个纹素
  • 设备沉睡的“心跳”难题:BLE休眠后无法被手机唤醒的分析与优化
  • 【计算机基础】网络系列(二)TCP
  • 网站seo整站优化淘宝网站的建设
  • Python 自动化导出PDF表格:List、Dictionary、Pandas DataFrame和数据库实例演示
  • GPT-5-Codex Prompting Guide|提示词指南
  • PDF转图片工具:基于PyQt5的完整实现与深度解析
  • 万兴PDF专家安装教程(附安装包)万兴PDF免费版下载详细安装图文教程
  • Codeforces Round 1052 (Div. 2) C. Wrong Binary Searchong Binary Search
  • 网站开始怎么做的做网站用php还是html
  • 算法基础篇(7)双指针
  • 从零开始学华为:Console口连接设备
  • 华为bgp路由的各种控制和团体属性及orf使用案例
  • 网站中的表单怎么做吉林网页制作公司