Python中的斑点(李过滤器) [英] Speckle ( Lee Filter) in Python

查看:111
本文介绍了Python中的斑点(李过滤器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试去除卫星SAR图像中的斑点噪声.我没有得到任何可以去除SAR图像中的斑点噪声的软件包.我已经尝试了pyradar,但是它可以与python 2.7一起使用,并且我正在Windows上使用python 3.5的Anaconda上工作.也可以使用Rsgislib,但它在Linux上.约瑟夫·梅林还在github上提供了Lee过滤器代码,但无法正常工作.:

如您所见,降噪效果总体上很好,但边缘却弱得多.

我对SAR不熟悉,所以我不知道Lee滤波器是否具有某些使其特别适合SAR斑点的功能,但是您可能想研究现代的边缘感知去噪器,例如引导滤波器或双边滤波器过滤器.

I am trying to do speckle noise removal in satellite SAR image.I am not getting any package which does speckle noise removal in SAR image. I have tried pyradar but it works with python 2.7 and I am working on Anaconda with python 3.5 on windows. Also Rsgislib is available but it is on Linux. Joseph meiring has also given a Lee filter code on github but it fails to work. : https://github.com/reptillicus/LeeFilter

Kindly, can anyone share the python script for Speckle Filter or how to proceed for speckle filter design in python.

解决方案

This is a fun little problem. Rather than try to find a library for it, why not write it from the definition?

from scipy.ndimage.filters import uniform_filter
from scipy.ndimage.measurements import variance

def lee_filter(img, size):
    img_mean = uniform_filter(img, (size, size))
    img_sqr_mean = uniform_filter(img**2, (size, size))
    img_variance = img_sqr_mean - img_mean**2

    overall_variance = variance(img)

    img_weights = img_variance / (img_variance + overall_variance)
    img_output = img_mean + img_weights * (img - img_mean)
    return img_output

If you don't want the window to be a square of size x size, just replace uniform_filter with something else (convolution with a disk, gaussian filter, etc). Any type of (weighted) averaging filter will do, as long as it is the same for calculating both img_mean and img_square_mean.

The Lee filter seems rather old-fashioned as a filter. It won't behave well at edges because for any window that has an edge in it, the variance is going to be much higher than the overall image variance, and therefore the weights (of the unfiltered image relative to the filtered image) are going to be close to 1.

An example:

from pylab import *
import numpy as np
img = np.random.normal(0.5, 0.1, (100,100))
img[:,:50] += 0.25
imshow(img, vmin=0, vmax=1, cmap='gray')
imshow(lee_filter(img, 20), vmin=0, vmax=1, cmap='gray')

As you can see the noise reduction is very good in general, but much weaker along the edge.

I'm not familiar with SAR so I don't know if Lee filter has some features that make it particularly good for speckle in SAR, but you may want to look into modern edge-aware denoisers, like guided filter or bilateral filter.

这篇关于Python中的斑点(李过滤器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆