形态学迭代关闭

Iterations in morphology closing

我的代码如下:

def blockKernel(sizeX, sizeY = None):
    if sizeY == None:
        sizeY = sizeX
    return np.ones((sizeX, sizeY), np.uint8)

img = readImage() // skipping readImage function, since irrelevant
closeBlock1 = cv.morphologyEx(img, cv.MORPH_CLOSE, blockKernel(3), iterations=1) 
closeBlock2 = cv.morphologyEx(img, cv.MORPH_CLOSE, blockKernel(3), iterations=3)

我得到以下输出:

closeBlock1:

closeBlock2:

但后来我看到了this。它说:

According to the "Digital Image Processing, 3rd edition", by Gonzales, The multiple application of opening/closing doesn't have any effect after the first time you apply it!

但这不是我得到的结果。我得到 1 vs 3 迭代,并得到不同的结果。我是做错了什么还是误解了什么?

cv.morphologyEx(img, cv.MORPH_CLOSE, blockKernel(3), iterations=3) 应用内核迭代的闭包,它不迭代闭包。

形态学闭合是先膨胀后腐蚀。此函数通过将 3x3 膨胀迭代三次来应用膨胀,然后通过再次将 3x3 腐蚀迭代三次来应用腐蚀。