Search in sources :

Example 1 with ErodeTransformer

use of org.jwildfire.transform.ErodeTransformer in project JWildfire by thargor6.

the class BaseFlameListCreator method preprocessImage.

private void preprocessImage(SimpleImage tImage) {
    if (imageParams.getErode() == 1) {
        long t0 = System.currentTimeMillis();
        ErodeTransformer eT = new ErodeTransformer();
        eT.initDefaultParams(tImage);
        eT.setMode(ErodeTransformer.Mode.DILATE);
        eT.setSize(imageParams.getErodeSize());
        eT.setShape(ErodeTransformer.Shape.DISK);
        eT.transformImage(tImage);
        long t1 = System.currentTimeMillis();
        statistics.getAction(ActionType.ERODE).setDuration(t1 - t0);
        currProgress += updatePreprocessStep;
        progressUpdater.updateProgress(currProgress);
    }
    List<SimpleImage> convImages = new ArrayList<SimpleImage>();
    if (imageParams.getConv_north() == 1) {
        long t0 = System.currentTimeMillis();
        SimpleImage north = tImage.clone();
        ConvolveTransformer transformer = new ConvolveTransformer();
        transformer.initDefaultParams(north);
        transformer.setKernelType(KernelType.SOBEL_3X3);
        transformer.setKernelDirection(KernelDirection.NORTH);
        transformer.setColorMode(ColorMode.GREY);
        transformer.transformImage(north);
        convImages.add(north);
        long t1 = System.currentTimeMillis();
        statistics.getAction(ActionType.CONV_NORTH).setDuration(t1 - t0);
        currProgress += updatePreprocessStep;
        progressUpdater.updateProgress(currProgress);
    }
    if (imageParams.getConv_east() == 1) {
        long t0 = System.currentTimeMillis();
        SimpleImage east = tImage.clone();
        ConvolveTransformer transformer = new ConvolveTransformer();
        transformer.initDefaultParams(east);
        transformer.setKernelType(KernelType.SOBEL_3X3);
        transformer.setKernelDirection(KernelDirection.EAST);
        transformer.setColorMode(ColorMode.GREY);
        transformer.transformImage(east);
        convImages.add(east);
        long t1 = System.currentTimeMillis();
        statistics.getAction(ActionType.CONV_EAST).setDuration(t1 - t0);
        currProgress += updatePreprocessStep;
        progressUpdater.updateProgress(currProgress);
    }
    if (imageParams.getConv_south() == 1) {
        long t0 = System.currentTimeMillis();
        SimpleImage south = tImage.clone();
        ConvolveTransformer transformer = new ConvolveTransformer();
        transformer.initDefaultParams(south);
        transformer.setKernelType(KernelType.SOBEL_3X3);
        transformer.setKernelDirection(KernelDirection.SOUTH);
        transformer.setColorMode(ColorMode.GREY);
        transformer.transformImage(south);
        convImages.add(south);
        long t1 = System.currentTimeMillis();
        statistics.getAction(ActionType.CONV_SOUTH).setDuration(t1 - t0);
        currProgress += updatePreprocessStep;
        progressUpdater.updateProgress(currProgress);
    }
    if (imageParams.getConv_west() == 1) {
        long t0 = System.currentTimeMillis();
        SimpleImage west = tImage.clone();
        ConvolveTransformer transformer = new ConvolveTransformer();
        transformer.initDefaultParams(west);
        transformer.setKernelType(KernelType.SOBEL_3X3);
        transformer.setKernelDirection(KernelDirection.WEST);
        transformer.setColorMode(ColorMode.GREY);
        transformer.transformImage(west);
        convImages.add(west);
        long t1 = System.currentTimeMillis();
        statistics.getAction(ActionType.CONV_WEST).setDuration(t1 - t0);
        currProgress += updatePreprocessStep;
        progressUpdater.updateProgress(currProgress);
    }
    if (convImages.size() == 1) {
        SimpleImage convImage = convImages.get(0);
        tImage.setBufferedImage(convImage.getBufferedImg(), convImage.getImageWidth(), convImage.getImageHeight());
    } else if (convImages.size() > 1) {
        long t0 = System.currentTimeMillis();
        for (int i = 0; i < tImage.getImageHeight(); i++) {
            for (int j = 0; j < tImage.getImageWidth(); j++) {
                int r = 0, g = 0, b = 0;
                for (SimpleImage convImage : convImages) {
                    r += convImage.getRValue(j, i);
                    g += convImage.getGValue(j, i);
                    b += convImage.getBValue(j, i);
                }
                r = Tools.roundColor((double) r / (double) convImages.size());
                g = Tools.roundColor((double) g / (double) convImages.size());
                b = Tools.roundColor((double) b / (double) convImages.size());
                tImage.setRGB(j, i, r, g, b);
            }
        }
        long t1 = System.currentTimeMillis();
        statistics.getAction(ActionType.CONV_MERGE).setDuration(t1 - t0);
        currProgress += updatePreprocessStep;
        progressUpdater.updateProgress(currProgress);
    }
}
Also used : ConvolveTransformer(org.jwildfire.transform.ConvolveTransformer) ErodeTransformer(org.jwildfire.transform.ErodeTransformer) SimpleImage(org.jwildfire.image.SimpleImage) ArrayList(java.util.ArrayList)

Example 2 with ErodeTransformer

use of org.jwildfire.transform.ErodeTransformer in project JWildfire by thargor6.

the class Dilate3PreFilter method apply.

@Override
public void apply(SimpleImage pImage) {
    ErodeTransformer eT = new ErodeTransformer();
    eT.initDefaultParams(pImage);
    eT.setMode(ErodeTransformer.Mode.DILATE);
    eT.setSize(3);
    eT.setShape(ErodeTransformer.Shape.DISK);
    eT.transformImage(pImage);
}
Also used : ErodeTransformer(org.jwildfire.transform.ErodeTransformer)

Example 3 with ErodeTransformer

use of org.jwildfire.transform.ErodeTransformer in project JWildfire by thargor6.

the class Dilate5PreFilter method apply.

@Override
public void apply(SimpleImage pImage) {
    ErodeTransformer eT = new ErodeTransformer();
    eT.initDefaultParams(pImage);
    eT.setMode(ErodeTransformer.Mode.DILATE);
    eT.setSize(5);
    eT.setShape(ErodeTransformer.Shape.DISK);
    eT.transformImage(pImage);
}
Also used : ErodeTransformer(org.jwildfire.transform.ErodeTransformer)

Aggregations

ErodeTransformer (org.jwildfire.transform.ErodeTransformer)3 ArrayList (java.util.ArrayList)1 SimpleImage (org.jwildfire.image.SimpleImage)1 ConvolveTransformer (org.jwildfire.transform.ConvolveTransformer)1