0
가장자리 감지 용 Sobele 필터를 구현하는 데 문제가 있습니다. 모든소벨 필터 기능
첫째, SOBEL_VERTICAL 및 SOBEL_HORIZONTAL 회선을 다음 공식을 이용하여 화소의 색상을 계산한다 : G = SQRT (GX * GX + Gy의 * Gy의)
번호 :
val log = KotlinLogging.logger { }
val width = fastImage.width
val height = fastImage.height
override fun filter(): FastImage {
val convolution = Convolution(fastImage)
val obsSobelHorizontal = Observable.fromCallable { convolution.convolve(Convolution.SOBEL_HORIZONTAL) }
val obsSobelVertical = Observable.fromCallable { convolution.convolve(Convolution.SOBEL_VERTICAL) }
var fastImageSobel: FastImage? = null
Observable.zip(obsSobelHorizontal, obsSobelVertical, { r1, r2 ->
log.info { Thread.currentThread() }
val fast = FastImage(width, height)
for (x in 0..width - 1) {
for (y in 0..height - 1) {
val argb1: Int? = r1.getARGB(x, y)
val argb2: Int? = r2.getARGB(x, y)
if (argb1 != null && argb2 != null) {
val G = sqrt(((argb1 * argb1) + (argb2 * argb2)).toDouble()).toInt().clamp()
val color = Color(G,G,G)
fast.setARGB(x, y, color.rgb)
}
}
}
[email protected] fast
}).subscribe({ fastImageSobel = it }, { log.error("Can`t do sobel!", it) })
return fastImageSobel!!
}
영수증과 자르기의 가장자리를 자동으로 감지 할 수 있습니까? –