抖动二值化 (:binarization)
Android 扩展
此功能为 Android 平台扩展,仅在 NBTouch (Android) 上可用。
声明
图像 = 图像:binarization([ 抖动算法类型 ])
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| 抖动算法类型 | 枚举型 | 可选,默认为 0 |
抖动算法类型枚举
| 值 | 说明 |
|---|---|
| 0 | DitherNone(无抖动) |
| 1 | DitherOrdered(有序抖动/Bayer 抖动) |
| 2 | DitherOrderedReproducible(可重现的有序抖动) |
| 3 | DitherFloydSteinberg(Floyd-Steinberg 误差扩散) |
| 4 | DitherAtkinson(Atkinson 误差扩散) |
返回值
| 返回值 | 类型 | 说明 |
|---|---|---|
| 图像 | 图片对象 | 二值化后返回图片对象本体 |
说明
使用抖动算法进行图片二值化。
不同于 :binaryzation(色偏法)和 :cv_binaryzation(阈值法),此函数使用图像抖动算法。
抖动算法对比
- DitherNone: 简单阈值二值化,无抖动效果
- DitherOrdered: 使用 Bayer 矩阵的有序抖动,适合保留图像细节
- DitherFloydSteinberg: 经典的误差扩散算法,效果自然
- DitherAtkinson: Macintosh 经典风格,保留更多高光细节
示例
local img = screen.image()
-- 使用 Floyd-Steinberg 抖动二值化
img:binarization(3)
img:save_to_album()