task 8.4
This commit is contained in:
parent
0657c28d7d
commit
979807f399
@ -99,6 +99,17 @@ object ImageFilters {
|
||||
Math.max(0, Math.min(255, value + (Math.random()*2-1)*intensity)).toInt
|
||||
})
|
||||
|
||||
def noise(a: Array[Array[Color]], intensity: Double): Array[Array[Color]] = colorFilter(a, (col) => {
|
||||
val r: Double = col.getRed + (Math.random()*2-1)*intensity
|
||||
val g: Double = col.getGreen + (Math.random()*2-1)*intensity
|
||||
val b: Double = col.getBlue + (Math.random()*2-1)*intensity
|
||||
new Color(
|
||||
Math.max(0, Math.min(255, r)).toInt,
|
||||
Math.max(0, Math.min(255, g)).toInt,
|
||||
Math.max(0, Math.min(255, b)).toInt
|
||||
)
|
||||
})
|
||||
|
||||
def mask(a: Array[Array[Color]], maskImg: Array[Array[Int]]): Array[Array[Color]] = {
|
||||
val maskWidth: Int = maskImg.length
|
||||
val maskHeight: Int = if (maskWidth == 0) 0 else maskImg(0).length
|
||||
|
@ -55,5 +55,7 @@ object ImageProcessingApp extends App {
|
||||
val imageFile: String = "./res/collins_eileen.png"
|
||||
val org = new ImageGraphics(imageFile, "Original", -768, -512)
|
||||
val sepia = new ImageGraphics(imageFile, "Sepia", -256, -512)
|
||||
val noise = new ImageGraphics(imageFile, "Noise", 256, -512)
|
||||
sepia.setPixelsColor(ImageFilters.sepia(org.getPixelsColor()))
|
||||
noise.setPixelsColor(ImageFilters.noise(org.getPixelsColor(), 50))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user