简体   繁体   English

调整自适应阈值参数背后的直觉

[英]Intuition behind adjusting adaptive thresholding parameters

While following this guide and using the adaptive thresholding function, I was confused about the intuition with adjusting the blocksize and C to find an ideal value.在遵循本指南并使用自适应阈值function 时,我对调整blocksizeC以找到理想值的直觉感到困惑。

What approach should one take when adjusting these parameters instead of doing a completely randomized guess and check process?在调整这些参数而不是进行完全随机的猜测和检查过程时应该采取什么方法? Is there a better technique for learning these parameters based on an image's color histrogram?有没有更好的技术可以根据图像的颜色直方图来学习这些参数?

cv2.adaptiveThreshold(img, maxValue, adaptiveMethod, thresholdType, blockSize, C)

The block size should be chosen such that a block always sees both foreground and background.应选择块大小以使块始终可以看到前景和背景。 If the block is too small, a block that is completely inside the foreground or background will not see the actual contrast in the region, it will only see the noise.如果块太小,完全在前景或背景内部的块将看不到该区域的实际对比度,它只会看到噪点。 Consequently, for that block, the thresholded result will not separate background and foreground, but noise within the single phase.因此,对于该块,阈值化结果不会分离背景和前景,而是单相内的噪声。

The threshold value C can be zero if every block sees a good amount of both phases.如果每个块都看到大量的两个阶段,则阈值C可以为零。

If the block size cannot be chosen large enough, and some blocks see only background, then the C value can be set large enough for these blocks to result in only background.如果无法选择足够大的块大小,并且某些块只能看到背景,则可以将C值设置得足够大,以使这些块仅产生背景。 Two times the standard deviation of the noise in the background is a good start value.背景噪声标准偏差的两倍是一个好的起始值。

Likewise, if it is the foreground phase that is larger, set C to a negative value such that a block completely in the foreground results in only foreground.同样,如果是前景相位较大,则将C设置为负值,以便完全位于前景中的块仅产生前景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM