1. 回顾: 双边滤波(BF)

具体参考上篇博客:图像滤波之双边滤波

2. 联合双边滤波(JBF)

联合双边滤波与双边滤波之间的差别就是JBF用了一个引导图作为值域权重的计算依据,但是空间域权重计算仍然基于原图:

3. 联合双边滤波代码

3.1 python opencv实现

import cv2
import matplotlib.pyplot as pltif __name__ == "__main__":image = cv2.imread('lena512.bmp', 0)[200:400, 200:400]blur_img = cv2.resize(image, (25, 25))blur_img = cv2.resize(blur_img, (200, 200))plt.figure()for i, sigma_color in enumerate([10, 100, 200]):for j, sigma_space in enumerate([10, 100, 200]):bf_img = cv2.ximgproc.jointBilateralFilter(blur_img, image, 9, sigma_color, sigma_space)plt.subplot(3, 3, i*3+j+1)plt.axis('off')plt.title('sigma_color: %d,sigma_space: %d' % (sigma_color, sigma_space))plt.imshow(bf_img, cmap='gray')plt.show()

3.2 纯python实现

import numpy as np
import cv2
import math
import matplotlib.pyplot as pltdef distance(x, y, i, j):return np.sqrt((x-i)**2 + (y-j)**2)def gaussian(x, sigma):return (1.0 / (2 * math.pi * (sigma ** 2))) * math.exp(- (x ** 2) / (2 * sigma ** 2))def joint_bilateral_filter(image, reference_image, diameter, sigma_color, sigma_space):assert image.shape == reference_image.shapewidth = image.shape[0]height = image.shape[1]radius = int(diameter / 2)out_image = np.zeros_like(image)print('===============START=================')for row in range(height):for col in range(width):current_pixel_filtered = 0weight_sum = 0  # for normalizefor semi_row in range(-radius, radius + 1):for semi_col in range(-radius, radius + 1):# calculate the convolution by traversing each close pixel within radiusif row + semi_row >= 0 and row + semi_row < height:row_offset = row + semi_rowelse:row_offset = 0if semi_col + col >= 0 and semi_col + col < width:col_offset = col + semi_colelse:col_offset = 0color_weight = gaussian(reference_image[row_offset][col_offset] - reference_image[row][col], sigma_color)space_weight = gaussian(distance(row_offset, col_offset, row, col), sigma_space)weight = space_weight * color_weightcurrent_pixel_filtered += image[row_offset][col_offset] * weightweight_sum += weightcurrent_pixel_filtered = current_pixel_filtered / weight_sumout_image[row, col] = int(round(current_pixel_filtered))print('===============FINISH=================')return out_imageif __name__ == "__main__":image = cv2.imread('lena512.bmp', 0)[200:400, 200:400]blur_img = cv2.resize(image, (25, 25))blur_img = cv2.resize(blur_img, (200, 200))plt.imshow(blur_img)plt.show()plt.figure()for i, sigma_color in enumerate([10, 100, 200]):for j, sigma_space in enumerate([10, 100, 200]):bf_img = joint_bilateral_filter(blur_img, image, 9, sigma_color, sigma_space)plt.subplot(3, 3, i*3+j+1)plt.axis('off')plt.title('sigma_color: %d,sigma_space: %d' % (sigma_color, sigma_space))plt.imshow(bf_img, cmap='gray')plt.show()

联合双边滤波-Joint Bilateral Filter相关推荐

  1. 双边滤波(Bilateral Filter)详解

    双边滤波(Bilateral Filter)详解 转自:睁开眼就变帅 原理分析: 双边滤波与高斯滤波器相比,对于图像的边缘信息能过更好的保存.其原理为一个与空间距离相关的高斯函数与一个灰度距离相关的高 ...

  2. 双边滤波(Bilateral filter)

    双边滤波器(Bilateral filter)是一种可以保边去噪的滤波器.可以滤除图像数据中的噪声,且还会保留住图像的边缘.纹理等(因噪声是高频信号,边缘.纹理也是高频信息,高斯滤波会在滤除噪声的同时 ...

  3. 双边滤波(bilateral filter)以及联合双边滤波(joint bilateral filter)

    文章目录 双边滤波 理论公式 代码(C++) 数学辅助理解 联合双边滤波(joint bilateral filter) 参考链接 写在最后 双边滤波 自用备忘,若侵则删. 理论公式 利用二维高斯函数 ...

  4. 联合双边滤波器(joint bilateral filter)

    原文地址: 联合双边滤波器(joint bilateral filter) 作者: pplong 前面介绍了双边滤波器(bilateral filter,LBF),然而BF的权值是不稳定的,因此在边缘 ...

  5. 【OpenCV 例程200篇】60. 非线性滤波—联合双边滤波

    [OpenCV 例程200篇]60. 非线性滤波-联合双边滤波(Joint bilateral filter) 欢迎关注 『OpenCV 例程200篇』 系列,持续更新中 欢迎关注 『Python小白 ...

  6. Bilateral Filter、Cross/Joint Bilateral Filter

    今天被问到cross bilateral Filter,虽然自己知道这肯定是一种滤波算法,但是究竟它和bilateral Filter有什么关系?觉得,作为一个图像处理研究者,一定要基础扎实,所以赶紧 ...

  7. games202:六,实时光线追踪RTRT:Temporal Filtering、联合双边滤波、Outlier Removal、SVGF、RAE

    games202:六,实时光线追踪RTRT:Temporal Filtering.联合双边滤波.Outlier Removal .SVGF.RAE RTRT现状 实时降噪方法 一,Temporal F ...

  8. 图像处理-双边滤波和联合双边滤波

    图像处理-双边滤波和联合双边滤波 双边滤波原理 ​ 双边滤波(Bilateral Filter)是一种非线性滤波器,可以达到保持边缘,降噪平滑的效果.其算法最早由C. Tomasi和R. Manduc ...

  9. 中值滤波,均值滤波,高斯滤波,双边滤波,联合双边滤波介绍

    看GAMES202相关课程发现闫老师讲的太好了,所以记录一下.当然文中涉及的PPT也来自闫老师的课程PPT,欢迎交流. 首先这几种都是空域的滤波方式,用于抑制图像中的噪声.它们采用的原理基本都是通过滤 ...

最新文章

  1. 关闭ubuntu启动时System Program Problem Detected提示
  2. php sprintf u,PHP sprintf()格式化用法详解
  3. Jaspersoft Studio简介
  4. windows10 下 用图片手把手教你 卸载 cygwin
  5. Spark远程调试配置,在IDEA中的配置
  6. Problem - 6111迷宫出逃
  7. android如何删除项目,AndroidStudio中怎样删除项目
  8. 搞IT也不能不懂“五险一金”啊
  9. 北语18春《计算机网络技术》作业4,北语18春《计算机网络技术》作业4
  10. 关于Linux服务器改变为普通用户进行运维的操作手记
  11. 免费电子书:Azure Web Apps开发者入门
  12. python 插值_有序点列的样条插值
  13. mysql 日期循环_如何在mysql存储过程中循环日期时间
  14. 转载--批量更新数据(性能优化)
  15. jqGrid Pager、Navigator和自定义按钮(转)
  16. FC SAN - 光纤通道存储区域网络
  17. Buffon投针试验【布丰】
  18. 使用 React Testing Library 和 Jest 完成单元测试
  19. swift 使用Moya进行网络请求
  20. 美国国家机器人计划2.0部分项目简介

热门文章

  1. vsnprintf长度
  2. 计算机毕设Python+Vue疫情医疗物资管理系统(程序+LW+部署)
  3. 机器学习四大降维方法
  4. 计算机中阶符,阶码,数符,尾数是什么?
  5. 建筑施工脚手架安全技术统一标准
  6. android应用程序框架图,Android系统框架图详解
  7. 【聊天表情包小程序的开发】之开发简介
  8. 吉大的计算机科学与技术,计算机科学与技术分中心
  9. 我的游戏--恶灵骑士4.0
  10. MBSE和SysML