task 5
This commit is contained in:
parent
54fa312113
commit
ddd8952e9a
@ -50,4 +50,13 @@ object ImageFilters {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def edges(a: Array[Array[Int]]): 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)(x+1) - a(y)(x-1)
|
||||||
|
val dy: Int = a(y+1)(x) - a(y-1)(x)
|
||||||
|
Math.sqrt(dx*dx + dy*dy).toInt
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,7 @@ object ImageProcessingApp extends App {
|
|||||||
|
|
||||||
val mean2 = new ImageGraphics("./res/imageProcessing.jpg", "Mean 2", 250, 250)
|
val mean2 = new ImageGraphics("./res/imageProcessing.jpg", "Mean 2", 250, 250)
|
||||||
mean2.setPixelsBW(ImageFilters.mean(mean2.getPixelsBW(), 4))
|
mean2.setPixelsBW(ImageFilters.mean(mean2.getPixelsBW(), 4))
|
||||||
|
|
||||||
|
val edges = new ImageGraphics("./res/rice.jpg", "Edges", 500, 250)
|
||||||
|
edges.setPixelsBW(ImageFilters.edges(edges.getPixelsBW()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user