我是靠谱客的博主 务实水壶,最近开发中收集的这篇文章主要介绍图片去除噪点,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

将图片进行二值化,灰度处理,判断为噪点即去除:

思路:

依次遍历图中所有非白色的点,计算其周围8个点中属于非白色点的个数,如果数量小于一个固定值,那么这个点就是噪点。

使用流程:

使用Opencv二值化 灰度处理 领域降噪,通过图片转base64传输进行降噪后再传出base64。 
示例:http://49.233.44.7:5000/
图片base64测试:
iVBORw0KGgoAAAANSUhEUgAAAFUAAAAjCAYAAADljkaGAAAKxUlEQVR42u1aeVTU9xHPv2o05jJNX9omJo1tamqsfUlTjS6eeF/xiHcOY1KvBI3GqFGb41U8MBovjAa5BLkEOVYEAZFDUFDCAnLfLPdyL+wun84MwUTYNSy6Ylrnvd+T3d/1nc935jOfmfUh3EM79vjz+H+wh+7Vi5oqquA2VNHjDn+oPIAabUO37k3KtEHENQWikiYhVjUHquytPQtqWcJ1BMxY3OOAquur0Nraava9qvOpyLoej3JNJNSVShSWeSJP7QydvqHnQM0PCUei3aEeBbWhRdstQNkaa5rQUN1gmfRvNbTC0KLDA7uLoFapbiDAekGPLrpFr6U0LkCu5gayq1NQ3VSBZSmroW/V/zpBVcdcwfn5H9zzhTbpGpBeeQ1Bmc44lvgFtl9civWhM7H6nDU+Oj8Fo/0GQZnlCr1B36UUL6nLQ2T+WTgm7YbdZRscSfgcoTkeyKxMhpY27Z6Cmh90ARc//NQsbqpOKEQLcdKd2A0CdFP4PIx1fRIjHHtD4dwfY1yegJXLoxju2Is+P4JpHs8R2MvQqGs0ub6KxhLYJ27DDI+BeMPpYYx06otRTv1gRc+bcOo3mE7fbwidTYD7EwfX3TtJ9cP+43R81+XrLyoOQt/UckegJpRE4LOwt/BV1Ps4nXIQ57NPI7ogCFfp+9BcL6xUjrsJ7olrX0tkd7Ta5mociN9IG/MERjj1wWyvQdgVswaeqYfhnnKANuRtTD39HD3jUSz2HQaX5L1o1jXdG1Djttoi0+1Ml69XDvzqjtOfOTS57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IyKbBxwMlE1Im17kg6dEBiODZu7S2tOWmw7WvGtoLe8FjKCOrq0R4Pv5/bOJfpwoI5IL45FV0HmwEpHvJ5qYe/sFvq+IamAa4GEKW5KfEpeivbAzZqVENetYu7j1luFU1oRKajNZ3POkh0dkh65uweGErcI9XGSmU6QZK0YthmbhU5Y6o6lIcETyJGiqx7N0Xx+87f96W3upM/7jHLeirB05EtvB5WkUH+2fp7o/KxkSnO0ukyVTCqKRNHB43hnaKKubkb2MJNT2yGUyvdqsnI93PV4X3cvAc/d1mWjNYh0Vc5+ryg5vuQ+GwqGf0AFHCKf8igCFtJgmqzMByzx1LvsUjiX+Gyeuf0UcuxfxJNTVdQUif0xFQ7sWZcHPA5nw3DOyeYFUlQMznEhrhklbzEqD9ekvRRXPSLk93hW7WgKkfcA97tQA8YnVAUtAHowH0PMbzZigdav3r6Iq6PDOLPhFHYBv+gmE5HggW5Nqhlg3yI91NSRnZFRoole/Hbh8DwPDfM2c2kyp21FvdtX45xeORJ8bx+CcvAffX/9aNpuHP9dKo2QjLT5QYTs9ZAy01Cl1R6R3ydGIsaj36YuWPFeL/6jIm8RTLe4YWTbxXLi6qbxbI8g7ArW+SG1RR5uiZ7eBmnEAvzZ76H5dmPbKcjSn7+/2/yh5AKoxUJM+RXPy5/g12n0LaltB0t8X69AWN/xvgHo/bW7Bt6oHoN5tUEucMh6A2tP2X8da3tqWwBkKAAAAAElFTkSuQmCC

代码测试:

import base64
import requests

# """图片转base64"""
# with open("test.png", 'rb') as f:
#     base64_data = base64.b64encode(f.read())
#     print(base64_data)

base64_data = 'iVBORw0KGgoAAAANSUhEUgAAAFUAAAAjCAYAAADljkaGAAAKxUlEQVR42u1aeVTU9xHPv2o05jJNX9omJo1tamqsfUlTjS6eeF/xiHcOY1KvBI3GqFGb41U8MBovjAa5BLkEOVYEAZFDUFDCAnLfLPdyL+wun84MwUTYNSy6Ylrnvd+T3d/1nc935jOfmfUh3EM79vjz+H+wh+7Vi5oqquA2VNHjDn+oPIA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YBv+gmE5HggW5Nqhlg3yI91NSRnZFRoole/Hbh8DwPDfM2c2kyp21FvdtX45xeORJ8bx+CcvAffX/9aNpuHP9dKo2QjLT5QYTs9ZAy01Cl1R6R3ydGIsaj36YuWPFeL/6jIm8RTLe4YWTbxXLi6qbxbI8g7ArW+SG1RR5uiZ7eBmnEAvzZ76H5dmPbKcjSn7+/2/yh5AKoxUJM+RXPy5/g12n0LaltB0t8X69AWN/xvgHo/bW7Bt6oHoN5tUEucMh6A2tP2X8da3tqWwBkKAAAAAElFTkSuQmCC'

"""调用Django-八领域降噪法"""
data = {"dep_url": base64_data, "submit": "搜索"}
response = requests.post("http://49.233.44.7:5000/", data)
print(response.text)
result = response.json().get("code")

"""写入本地查看"""
with open('result.jpg', 'wb') as file:
    file.write(base64.b64decode(result))

结果展示:

在这里插入图片描述

最后

以上就是务实水壶为你收集整理的图片去除噪点的全部内容,希望文章能够帮你解决图片去除噪点所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部