मैटलैब infill() बदले में एक फ़ंक्शन IM = imreconstruct (मार्कर, मास्क)
साइकिट-छवि का समान उपयोग होता है । सिद्धांतों और अनुप्रयोग, स्प्रिंगर-वर्लग, 1999, पीपी 208-209: समारोह ... skimage.morphology.reconstruction(seed, mask, method='dilation', selem=None, offset=None)
एल्गोरिथ्म Soille, पी, रूपात्मक छवि विश्लेषण में विस्तृत है। खंड 6.3.7 अनुभाग "Fillhole"
import numpy as np
from skimage.morphology import reconstruction
import matplotlib.pyplot as plt
from skimage.io import imread, imsave
# Use the matlab reference Soille, P., Morphological Image Analysis: Principles and Applications, Springer-Verlag, 1999, pp. 208-209.
# 6.3.7 Fillhole
# The holes of a binary image correspond to the set of its regional minima which
# are not connected to the image border. This definition holds for grey scale
# images. Hence, filling the holes of a grey scale image comes down to remove
# all minima which are not connected to the image border, or, equivalently,
# impose the set of minima which are connected to the image border. The
# marker image 1m used in the morphological reconstruction by erosion is set
# to the maximum image value except along its border where the values of the
# original image are kept:
img = imread("tyre.jpg")
seed = np.ones_like(img)*255
img[ : ,0] = 0
img[ : ,-1] = 0
img[ 0 ,:] = 0
img[ -1 ,:] = 0
seed[ : ,0] = 0
seed[ : ,-1] = 0
seed[ 0 ,:] = 0
seed[ -1 ,:] = 0
fill = reconstruction(seed, img, method='erosion')
f, (ax0, ax1) = plt.subplots(1, 2,
subplot_kw={'xticks': [], 'yticks': []},
figsize=(12, 8))
ax0.imshow(img)
ax1.imshow(fill)
plt.show()
Link to tyre image and filled image
चेक [इस लिंक] (http://www.learnopencv.com/filling-holes-in-an-image-using-opencv-python -सी /) इसके पाइथन कार्यान्वयन को देखने के लिए। –
@BillBEGUERADJ यह बाइनरी छवियों के लिए है। ओपी ग्रेस्केल छवियों के लिए ऐसा करना चाहता है। – rayryeng