第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法通過 remove_small_objects 去除噪音

無法通過 remove_small_objects 去除噪音

萬千封印 2021-11-30 10:23:15
我有一個黑白圖像。我嘗試通過 消除噪音remove_small_objects。import cv2 as cvimport numpy as npfrom skimage import morphologyimg = np.array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],                [255, 255,   0, 255,   0,   0,   0,   0, 255, 255, 255],                [255, 255, 255, 255,   0,   0,   0,   0, 255,   0,   0],                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0],                [255, 255,   0,   0,   0,   0,   0, 255,   0,   0,   0],                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0],                [255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0],                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0],                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0]])cleaned = morphology.remove_small_objects(img, min_size=10, connectivity=1)print(cleaned)while True:    cv.imshow('Demo', cleaned.astype(np.uint8))    if cv.waitKey(1) & 0xFF == 27:        breakcv.destroyAllWindows()然而,它并沒有像我預期的那樣工作。中間的白色像素 255 仍然存在。我做錯什么了嗎?謝謝
查看完整描述

1 回答

?
守候你守候我

TA貢獻1802條經(jīng)驗 獲得超10個贊

從文檔(強調(diào)我的):


skimage.morphology.remove_small_objects(ar, min_size=64, connectivity=1, in_place=False)


刪除小于指定大小的對象。


期望 ar 是一個帶有標記對象的數(shù)組,并刪除小于 min_size 的對象。如果 ar 為 bool,則首先標記圖像。這導致 bool 和 0-and-1 數(shù)組的行為可能不同。


import numpy as np

from skimage import io, morphology

import matplotlib.pyplot as plt


img = np.array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],

                [255, 255,   0, 255,   0,   0,   0,   0, 255, 255, 255],

                [255, 255, 255, 255,   0,   0,   0,   0, 255,   0,   0],

                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0],

                [255, 255,   0,   0,   0,   0,   0, 255,   0,   0,   0],

                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0],

                [255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0],

                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0],

                [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0]])


arr = img > 0

cleaned = morphology.remove_small_objects(arr, min_size=2)

cleaned = morphology.remove_small_holes(cleaned, min_size=2)


fig, axs = plt.subplots(1, 2)

axs[0].imshow(img, cmap='gray')

axs[0].set_title('img')

axs[1].imshow(cleaned, cmap='gray')

axs[1].set_title('cleaned')

plt.show(fig)

http://img1.sycdn.imooc.com//61a58b370001350f03660170.jpg

查看完整回答
反對 回復 2021-11-30
  • 1 回答
  • 0 關(guān)注
  • 204 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號