package io.gitlab.jfronny.ImgJava;

import io.gitlab.jfronny.ImgJava.imageProcessing.UtilColor;
import io.gitlab.jfronny.ImgJava.imageProcessing.UtilGeometric;
import io.gitlab.jfronny.ImgJava.imageProcessing.UtilMatrix;
import io.gitlab.jfronny.ImgJava.util.ImageStackViewer;
import io.gitlab.jfronny.ImgJava.util.Picture;

import java.awt.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static void main(String[] args) {
        try {
            ImageStackViewer stackViewer = new ImageStackViewer(new Dimension(1000, 1000));
            stackViewer.setTitle("Jf Example");
            Path run = Paths.get("./run/");
            if (!Files.isDirectory(run))
                Files.createDirectory(run);
            Picture pict = stackViewer.push(new Picture("iris.jpg"));
            pict = stackViewer.push(UtilGeometric.mirror(pict, UtilGeometric.MirrorMode.Horizontal));
            pict = stackViewer.push(UtilGeometric.mirror(pict, UtilGeometric.MirrorMode.Vertical));
            pict = stackViewer.push(UtilGeometric.rotate(pict, UtilGeometric.RotateMode.Left));
            pict = stackViewer.push(UtilGeometric.rotate(pict, UtilGeometric.RotateMode.Right));
            pict = stackViewer.push(UtilGeometric.mirror(pict, UtilGeometric.MirrorMode.Vertical));
            stackViewer.push(UtilMatrix.blurBox(new Picture(pict), 10));
            pict = stackViewer.push(UtilMatrix.blurGauss(pict, 3, 2));
            pict = stackViewer.push(UtilMatrix.sharpen(pict, 3));
            pict = stackViewer.push(UtilColor.invert(pict));
            pict = stackViewer.push(UtilColor.switcheroo(pict));
            pict = stackViewer.push(UtilColor.tint(pict, new Color(255, 0, 0, 128)));
            pict = stackViewer.push(UtilColor.tint(pict, new Color(0, 255, 0, 0)));
            pict = stackViewer.push(UtilColor.tint(pict, new Color(0, 0, 255, 255)));
            stackViewer.push(UtilColor.grayscale(new Picture(pict), UtilColor.GrayscaleMode.Avg));
            stackViewer.push(UtilColor.grayscale(new Picture(pict), UtilColor.GrayscaleMode.Min));
            stackViewer.push(UtilColor.grayscale(new Picture(pict), UtilColor.GrayscaleMode.Max));
            pict = stackViewer.push(UtilColor.grayscale(pict, UtilColor.GrayscaleMode.Natural));
            pict.save(run.resolve("moscov.png"));
            stackViewer.repaint();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
