diff --git a/spatial-temporal-denoising-B/README.md b/spatial-temporal-denoising-B/README.md new file mode 100644 index 0000000..7d4413b --- /dev/null +++ b/spatial-temporal-denoising-B/README.md @@ -0,0 +1,14 @@ +局部降噪B组 + +conda env create --file environment.yml + +conda install --file requirements.txt -y + +pip install -e . + +测试方法: +pytest --cov-report=html --cov=temporal_denoising --ignore=temporal_denoising.py test_denoising.py +根据输出的html可知覆盖率达到100% +不过依旧是个很简单的实现 +还有待进一步优化 +有一些备用图像可以测试看看 \ No newline at end of file diff --git a/spatial-temporal-denoising-B/backup_images/20090620163815498.jpg b/spatial-temporal-denoising-B/backup_images/20090620163815498.jpg new file mode 100644 index 0000000..6efeea8 Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/20090620163815498.jpg differ diff --git a/spatial-temporal-denoising-B/backup_images/90.jpg b/spatial-temporal-denoising-B/backup_images/90.jpg new file mode 100644 index 0000000..f2c0cec Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/90.jpg differ diff --git a/spatial-temporal-denoising-B/backup_images/result.jpg b/spatial-temporal-denoising-B/backup_images/result.jpg new file mode 100644 index 0000000..445e498 Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/result.jpg differ diff --git a/spatial-temporal-denoising-B/backup_images/result1.jpg b/spatial-temporal-denoising-B/backup_images/result1.jpg new file mode 100644 index 0000000..aca4a9c Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/result1.jpg differ diff --git a/spatial-temporal-denoising-B/backup_images/source.jpg b/spatial-temporal-denoising-B/backup_images/source.jpg new file mode 100644 index 0000000..6249aa7 Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/source.jpg differ diff --git a/spatial-temporal-denoising-B/backup_images/source1.jpg b/spatial-temporal-denoising-B/backup_images/source1.jpg new file mode 100644 index 0000000..6408853 Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/source1.jpg differ diff --git a/spatial-temporal-denoising-B/backup_images/timg.jpg b/spatial-temporal-denoising-B/backup_images/timg.jpg new file mode 100644 index 0000000..62f195d Binary files /dev/null and b/spatial-temporal-denoising-B/backup_images/timg.jpg differ diff --git a/spatial-temporal-denoising-B/cover_rate.PNG b/spatial-temporal-denoising-B/cover_rate.PNG new file mode 100644 index 0000000..5f36216 Binary files /dev/null and b/spatial-temporal-denoising-B/cover_rate.PNG differ diff --git a/spatial-temporal-denoising-B/result.jpg b/spatial-temporal-denoising-B/result.jpg new file mode 100644 index 0000000..4dc23dd Binary files /dev/null and b/spatial-temporal-denoising-B/result.jpg differ diff --git a/spatial-temporal-denoising-B/source.jpg b/spatial-temporal-denoising-B/source.jpg new file mode 100644 index 0000000..6249aa7 Binary files /dev/null and b/spatial-temporal-denoising-B/source.jpg differ diff --git a/spatial-temporal-denoising-B/temporal_denoising.py b/spatial-temporal-denoising-B/temporal_denoising.py new file mode 100644 index 0000000..cc7255a --- /dev/null +++ b/spatial-temporal-denoising-B/temporal_denoising.py @@ -0,0 +1,80 @@ +#coding:utf-8 +#测试用库 +import unittest + +import sys,os +from PIL import Image,ImageDraw + +#使用二值判断方法,如果确认是噪声,用该点周围灰度的均值进行替换 +def getPixel(image,x,y,G,N): + L = image.getpixel((x,y)) + if L > G: + L = True + else: + L = False + + nearDots = 0 + if L == (image.getpixel((x - 1,y - 1)) > G): + nearDots += 1 + if L == (image.getpixel((x - 1,y)) > G): + nearDots += 1 + if L == (image.getpixel((x - 1,y + 1)) > G): + nearDots += 1 + if L == (image.getpixel((x,y - 1)) > G): + nearDots += 1 + if L == (image.getpixel((x,y + 1)) > G): + nearDots += 1 + if L == (image.getpixel((x + 1,y - 1)) > G): + nearDots += 1 + if L == (image.getpixel((x + 1,y)) > G): + nearDots += 1 + if L == (image.getpixel((x + 1,y + 1)) > G): + nearDots += 1 + if nearDots < N: + a = (image.getpixel((x - 1,y - 1)) + + image.getpixel((x - 1,y)) + + image.getpixel((x - 1,y + 1)) + + image.getpixel((x,y - 1)) + + image.getpixel((x,y + 1)) + + image.getpixel((x + 1,y - 1)) + + image.getpixel((x + 1,y)) + + image.getpixel((x + 1,y + 1)))/8 + return int(a) +# return image.getpixel((x,y-1)) + else: + return None + +# 根据一个点A的灰度值,与周围的8个点的灰度值比较,设定一个值N(0