资源简介
使用C++与Python实现的引导滤波(guided image filter)代码,附件中包含一个cpp文件、一个python文件与一张测试图像。
博客链接为:https://blog.csdn.net/u013921430/article/details/99695647
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Sat Aug 17 18:46:20 2019
@author: 不用先生
“““
import cv2
import numpy as np
input_fn=‘03.jpg‘
def my_guidedFilter_oneChannel(srcImgguidedImgrad=9eps=0.01):
srcImg=srcImg/255.0
guidedImg=guidedImg/255.0
img_shape=np.shape(srcImg)
# dstImg=np.zeros(img_shapedtype=float)
#
# P_mean=np.zeros(img_shapedtype=float)
# I_mean=np.zeros(img_shapedtype=float)
# I_square_mean=np.zeros(img_shapedtype=float)
# I_mul_P_mean=np.zeros(img_shapedtype=float)
# var_I=np.zeros(img_shapedtype=float)
# cov_I_P=np.zeros(img_shapedtype=float)
#
# a=np.zeros(img_shapedtype=float)
# b=np.zeros(img_shapedtype=float)
# a_mean=np.zeros(img_shapedtype=float)
# b_mean=np.zeros(img_shapedtype=float)
P_mean=cv2.boxFilter(srcImg -1 (rad rad) normalize=True)
I_mean=cv2.boxFilter(guidedImg-1 (rad rad) normalize=True)
I_square_mean=cv2.boxFilter(np.multiply(guidedImgguidedImg) -1 (rad rad) normalize=True)
I_mul_P_mean=cv2.boxFilter(np.multiply(srcImgguidedImg) -1 (rad rad) normalize=True)
var_I=cv2.boxFilter(I_square_mean-np.multiply(I_meanI_mean) -1 (rad rad) normalize=True)
cov_I_P=cv2.boxFilter(I_mul_P_mean-np.multiply(I_meanP_mean) -1 (rad rad) normalize=True)
a=cov_I_P/(var_I+eps)
b=P_mean-np.multiply(aI_mean)
a_mean=cv2.boxFilter(a -1 (rad rad) normalize=True)
b_mean=cv2.boxFilter(b -1 (rad rad) normalize=True)
dstImg=np.multiply(a_meanguidedImg)+b_mean
return dstImg*255.0
def my_guidedFilter_threeChannel(srcImgguidedImgrad=9eps=0.01):
img_shape=np.shape(srcImg)
dstImg=np.zeros(img_shapedtype=float)
for ind in range(0img_shape[2]):
dstImg[::ind]=my_guidedFilter_oneChannel(srcImg[::ind]
guidedImg[::ind]radeps)
dstImg=dstImg.astype(np.uint8)
return dstImg
def main():
img=cv2.imread(input_fn)
print(np.shape(img))
dstimg=my_guidedFilter_threeChannel(imgimg90.01)
print(np.shape(dstimg))
# cv2.imwrite(‘output.jpg‘dstimg)
cv2.imshow(‘output‘dstimg)
cv2.waitKey(0)
if __name__ == ‘__main__‘:
main()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 81718 2018-11-25 20:33 引导滤波_Cpp_Python\03.jpg
文件 2342 2019-08-17 22:47 引导滤波_Cpp_Python\guided filter.py
文件 5024 2019-08-18 10:02 引导滤波_Cpp_Python\guidedFilter.cpp
目录 0 2019-08-18 10:03 引导滤波_Cpp_Python
----------- --------- ---------- ----- ----
89084 4
- 上一篇:自适应图像增强完整OpenCV代码
- 下一篇:QT录屏源码 ,无BUG
相关资源
- 自适应图像增强完整OpenCV代码
- 在mfc中picture控件中显示Mat图片
- OpenCv实现两个图片的相似度
- opencv椭圆拟合长短轴比
- Retinex算法,C++,opencv
- 利用opencv实现的条形码检测与识别C
- Opencv2.4.12 SVM手写数字识别
- opencv 正脸+左右侧脸全检测
- 激光雷达数据读取、显示、分割、直
- CvvImage类库
- 基于opencv的C++人眼识别以及眨眼检测
- 在VS2012上基于opencv的C++人眼识别与眨
- 基于暗通道和导向滤波的图像去雾算
- 根据原图和二值图得到分割彩图
- qt界面化实现各种滤波函数
- c#通过dll读取opencv里的mat图片
- linux opencv车牌识别
- opencv多视频同一窗口显示C++程序
- 基于opencv的手势识别
- 利用opencv做的垃圾检测代码
- Opencv3.0 鱼眼相机标定fisheye
- LSD直线提取算法Opencv
- 使用vc++6.0调用opencv库函数生成5*5单位
- opencv绘制点与坐标系
- 基于socket和opencv在linux中实现摄像头实
- 图片浏览器实现和图像编辑器实现源
- danmu 基于opencv平台编写的单目相机标
- OpenCV边缘检测程序 by浅墨
- c++视频教程opencv视频图像处理机器视
- OpenCV单目视觉定位测量C++代码
评论
共有 条评论