task 6
This commit is contained in:
@@ -59,4 +59,13 @@ object ImageFilters {
|
||||
Math.sqrt(dx*dx + dy*dy).toInt
|
||||
}
|
||||
})
|
||||
|
||||
def sobel(a: Array[Array[Int]], intensityFactor: Double): Array[Array[Int]] = filter(a, (value, x, y, width, height) => {
|
||||
if (x == 0 || x == width - 1 || y == 0 || y == height - 1) value
|
||||
else {
|
||||
val dx: Int = a(y-1)(x+1) + 2*a(y)(x+1) + a(y+1)(x+1) - a(y-1)(x-1) - 2*a(y)(x-1) - a(y+1)(x-1)
|
||||
val dy: Int = a(y+1)(x-1) + 2*a(y+1)(x) + a(y+1)(x+1) - a(y-1)(x-1) - 2*a(y-1)(x) - a(y-1)(x+1)
|
||||
(Math.sqrt(dx*dx + dy*dy)*intensityFactor).toInt
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user