65 lines
3.0 KiB
Scala
65 lines
3.0 KiB
Scala
package imagefilters
|
|
|
|
import isc.graphics.ImageGraphics
|
|
|
|
object ImageProcessingApp extends App {
|
|
|
|
/*val imageFile = "./res/collins_eileen.png"
|
|
val org = new ImageGraphics(imageFile, "Original", -500, -250)
|
|
val dest = new ImageGraphics(imageFile, "Duplicate", 0, -250)
|
|
val thresh = new ImageGraphics(imageFile, "Threshold", -500, 250)
|
|
|
|
// Simple copy and display
|
|
val newPixels = ImageFilters.duplicate(org.getPixelsBW())
|
|
dest.setPixelsBW(newPixels)
|
|
|
|
thresh.setPixelsBW(ImageFilters.threshold(newPixels, 128))
|
|
|
|
val mean = new ImageGraphics("./res/imageProcessing.jpg", "Mean", 0, 250)
|
|
mean.setPixelsBW(ImageFilters.mean(mean.getPixelsBW()))
|
|
|
|
val mean2 = new ImageGraphics("./res/imageProcessing.jpg", "Mean 2", 250, 250)
|
|
mean2.setPixelsBW(ImageFilters.mean(mean2.getPixelsBW(), 4))
|
|
|
|
val edges = new ImageGraphics("./res/rice.jpg", "Edges", 500, 250)
|
|
edges.setPixelsBW(ImageFilters.edges(edges.getPixelsBW()))*/
|
|
|
|
/*val imageFile: String = "./res/grace_hopper.jpg"
|
|
val org = new ImageGraphics(imageFile, "Original", -768, -512)
|
|
val bw = new ImageGraphics(imageFile, "Black & White", -256, -512)
|
|
val threshold = new ImageGraphics(imageFile, "Threshold", 256, -512)
|
|
val blur = new ImageGraphics(imageFile, "Blurred", -768, 0)
|
|
val edges = new ImageGraphics(imageFile, "Edge detection", -256, 0)
|
|
val sobel = new ImageGraphics(imageFile, "Sobel", 256, 0)
|
|
val noise = new ImageGraphics(imageFile, "Noise", -768, 512)
|
|
|
|
bw.setPixelsBW(ImageFilters.duplicate(org.getPixelsBW()))
|
|
threshold.setPixelsBW(ImageFilters.threshold(org.getPixelsBW(), 128))
|
|
blur.setPixelsBW(ImageFilters.mean(org.getPixelsBW(), 3))
|
|
edges.setPixelsBW(ImageFilters.edges(org.getPixelsBW()))
|
|
sobel.setPixelsBW(ImageFilters.sobel(org.getPixelsBW(), 0.3))
|
|
noise.setPixelsBW(ImageFilters.noise(org.getPixelsBW(), 30))*/
|
|
|
|
/*val imageFile: String = "./res/collins_eileen.png"
|
|
val maskFile: String = "./res/mask.png"
|
|
val org = new ImageGraphics(imageFile, "Original", -768, -512)
|
|
val mask = new ImageGraphics(maskFile, "Mask", -256, -512)
|
|
val masked = new ImageGraphics(imageFile, "Masked", 256, -512)
|
|
masked.setPixelsColor(ImageFilters.mask(org.getPixelsColor(), mask.getPixelsBW()))*/
|
|
|
|
/*val imageFile: String = "./res/grace_hopper.jpg"
|
|
val org = new ImageGraphics(imageFile, "Original", -768, -512)
|
|
val pixelated = new ImageGraphics(imageFile, "Pixelated", -256, -512)
|
|
pixelated.setPixelsColor(ImageFilters.pixelize(org.getPixelsColor(), 30, 130, 120, 400, 230))*/
|
|
|
|
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)
|
|
val mask = new ImageGraphics("./res/mask.png", "Mask", -256, -256)
|
|
val masked = new ImageGraphics(imageFile, "Masked", 256, -256)
|
|
sepia.setPixelsColor(ImageFilters.sepia(org.getPixelsColor()))
|
|
noise.setPixelsColor(ImageFilters.noise(org.getPixelsColor(), 50))
|
|
masked.setPixelsColor(ImageFilters.mask(org.getPixelsColor(), mask.getPixelsBW()))
|
|
}
|