Example usage for java.awt.image BufferedImage setRGB

List of usage examples for java.awt.image BufferedImage setRGB

Introduction

In this page you can find the example usage for java.awt.image BufferedImage setRGB.

Prototype

public void setRGB(int x, int y, int rgb) 

Source Link

Document

Sets a pixel in this BufferedImage to the specified RGB value.

Usage

From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java

public static void fadeImages(BufferedImage source1, BufferedImage source2, BufferedImage target, int relX,
        int targetX) {
    int pixel1, pixel2, newPixel;
    double f;//from  w ww .j av  a 2 s. co  m
    int r1, g1, b1, r2, g2, b2;
    byte newR, newG, newB;
    ColorModel cm = source1.getColorModel();

    for (int x = relX; x < source1.getWidth(); x++) {
        f = linearF(x, relX, source1.getWidth());
        for (int y = 0; y < source1.getHeight(); y++) {
            pixel1 = source1.getRGB(x, y);
            pixel2 = source2.getRGB(x - relX, y);

            r1 = cm.getRed(pixel1);
            g1 = cm.getGreen(pixel1);
            b1 = cm.getBlue(pixel1);
            r2 = cm.getRed(pixel2);
            g2 = cm.getGreen(pixel2);
            b2 = cm.getBlue(pixel2);

            int tr = 10;

            if (r1 < tr && g1 < tr && b1 < tr) {
                newPixel = pixel2;
            } else if (r2 < tr && g2 < tr && b2 < tr) {
                newPixel = pixel1;
            } else {
                newR = (byte) Math.round(((double) r1) * (1 - f) + ((double) r2) * f);
                newG = (byte) Math.round(((double) g1) * (1 - f) + ((double) g2) * f);
                newB = (byte) Math.round(((double) b1) * (1 - f) + ((double) b2) * f);
                newPixel = (newR & 0xff) << 16 | (newG & 0xff) << 8 | (newB & 0xff) << 0;
            }
            target.setRGB(x + targetX, y, newPixel);
        }

    }
}

From source file:de._13ducks.cor.graphics.GraphicsComponent.java

protected void calcColoredMaps(Color[] colors) {
    // Berechnet die eingefrbten Texturen, z.B. fr Gebude
    ArrayList<CoRImage> tList = new ArrayList<CoRImage>();
    tList.addAll(coloredImgMap.values());
    coloredImgMap.clear();//from  w  w  w .ja v a  2 s .  c  o  m
    for (int i = 0; i < tList.size(); i++) {
        BufferedImage im = (BufferedImage) tList.get(i).getImage();
        for (int playerId = 0; playerId < colors.length; playerId++) {
            BufferedImage preImg = new BufferedImage(im.getWidth(), im.getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            for (int x = 0; x < im.getWidth(); x++) {
                for (int y = 0; y < im.getHeight(); y++) {
                    // Das ganze Raster durchgehen und Farben ersetzen
                    // Ersetzfarbe da?
                    int rgb = im.getRGB(x, y);

                    float[] col = Color.RGBtoHSB((rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff, null);
                    if (col[0] >= 0.8583333f && col[0] <= 0.8666666f) {
                        // Ja, ersetzen
                        Color tc = colors[playerId];
                        int targetC = Color.HSBtoRGB(
                                Color.RGBtoHSB(tc.getRed(), tc.getGreen(), tc.getBlue(), null)[0], 1.0f,
                                col[2]);
                        int a = (rgb >> 24) & 0xff;
                        targetC = (targetC & (~(0xff << 24)) | (a << 24));
                        preImg.setRGB(x, y, targetC);

                    } else {
                        preImg.setRGB(x, y, im.getRGB(x, y));
                    }
                }
            }
            // Bild berechnet, einfgen
            CoRImage newImg = new CoRImage(preImg);
            newImg.setImageName(tList.get(i).getImageName());
            coloredImgMap.put(newImg.getImageName() + playerId, newImg);
        }

    }
}

From source file:PNGDecoder.java

/**
 * Decodes image from an input stream passed into constructor.
 * @return a BufferedImage object/*from   www . jav a 2  s. c om*/
 * @throws IOException
 */
public BufferedImage decode() throws IOException {

    byte[] id = read(12);
    checkEquality(id, new byte[] { -119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13 });

    byte[] ihdr = read(4);
    checkEquality(ihdr, "IHDR".getBytes());

    int width = readInt();
    int height = readInt();

    BufferedImage result = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    byte[] head = read(5);
    int mode;
    if (compare(head, new byte[] { 1, 0, 0, 0, 0 })) {
        mode = PNGEncoder.BW_MODE;
    } else if (compare(head, new byte[] { 8, 0, 0, 0, 0 })) {
        mode = PNGEncoder.GREYSCALE_MODE;
    } else if (compare(head, new byte[] { 8, 2, 0, 0, 0 })) {
        mode = PNGEncoder.COLOR_MODE;
    } else {
        throw (new RuntimeException("Format error"));
    }

    readInt();//!!crc

    int size = readInt();

    byte[] idat = read(4);
    checkEquality(idat, "IDAT".getBytes());

    byte[] data = read(size);

    Inflater inflater = new Inflater();
    inflater.setInput(data, 0, size);

    int color;

    try {
        switch (mode) {
        case PNGEncoder.BW_MODE: {
            int bytes = (int) (width / 8);
            if ((width % 8) != 0) {
                bytes++;
            }
            byte colorset;
            byte[] row = new byte[bytes];
            for (int y = 0; y < height; y++) {
                inflater.inflate(new byte[1]);
                inflater.inflate(row);
                for (int x = 0; x < bytes; x++) {
                    colorset = row[x];
                    for (int sh = 0; sh < 8; sh++) {
                        if (x * 8 + sh >= width) {
                            break;
                        }
                        if ((colorset & 0x80) == 0x80) {
                            result.setRGB(x * 8 + sh, y, Color.white.getRGB());
                        } else {
                            result.setRGB(x * 8 + sh, y, Color.black.getRGB());
                        }
                        colorset <<= 1;
                    }
                }
            }
        }
            break;
        case PNGEncoder.GREYSCALE_MODE: {
            byte[] row = new byte[width];
            for (int y = 0; y < height; y++) {
                inflater.inflate(new byte[1]);
                inflater.inflate(row);
                for (int x = 0; x < width; x++) {
                    color = row[x];
                    result.setRGB(x, y, (color << 16) + (color << 8) + color);
                }
            }
        }
            break;
        case PNGEncoder.COLOR_MODE: {
            byte[] row = new byte[width * 3];
            for (int y = 0; y < height; y++) {
                inflater.inflate(new byte[1]);
                inflater.inflate(row);
                for (int x = 0; x < width; x++) {
                    result.setRGB(x, y, ((row[x * 3 + 0] & 0xff) << 16) + ((row[x * 3 + 1] & 0xff) << 8)
                            + ((row[x * 3 + 2] & 0xff)));
                }
            }
        }
        }
    } catch (DataFormatException e) {
        throw (new RuntimeException("ZIP error" + e));
    }

    readInt();//!!crc
    readInt();//0

    byte[] iend = read(4);
    checkEquality(iend, "IEND".getBytes());

    readInt();//!!crc
    in.close();

    return (result);
}

From source file:com.simiacryptus.mindseye.lang.Tensor.java

/**
 * To rgb png buffered png.//  www.j  a  v a  2 s. com
 *
 * @param redBand   the red band
 * @param greenBand the green band
 * @param blueBand  the blue band
 * @return the buffered png
 */
@Nonnull
public BufferedImage toRgbImage(final int redBand, final int greenBand, final int blueBand) {
    assertAlive();
    @Nonnull
    final int[] dims = getDimensions();
    @Nonnull
    final BufferedImage img = new BufferedImage(dims[0], dims[1], BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < img.getWidth(); x++) {
        for (int y = 0; y < img.getHeight(); y++) {
            if (getDimensions()[2] == 1) {
                final double value = this.get(x, y, 0);
                img.setRGB(x, y, Tensor.bound8bit((int) value) * 0x010101);
            } else {
                final double red = Tensor.bound8bit(this.get(x, y, redBand));
                final double green = Tensor.bound8bit(this.get(x, y, greenBand));
                final double blue = Tensor.bound8bit(this.get(x, y, blueBand));
                img.setRGB(x, y, (int) (red + ((int) green << 8) + ((int) blue << 16)));
            }
        }
    }
    return img;
}

From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java

public BufferedImage getFlattenedImage(boolean overlayAscan) {

    ROIPanel pan = view;/*from   w  w  w .j  av  a 2s  . c o  m*/
    BufferedImage rst = previewPanel.getImage();
    if (axis == AXIS_Y) {
        int wide = 0;
        for (int i = 0; i < pan.getImage().getWidth(); i++) {
            if (getUseData(i)) {
                wide++;
            }
        }

        if (rst == null || rst.getWidth() != wide || rst.getHeight() != pan.getImage().getHeight()) {
            rst = ImageOperations.getBi(wide, pan.getImage().getHeight());
        } else {
            ImageOperations.setImage(Color.BLACK, rst);
        }
        // This will get the smoothed out aScan from the Dynamic?Range panel
        int posX = 0;
        int posY = 0;

        for (int i = 0; i < pan.getImage().getWidth(); i++) {
            posY = 0;

            if (getUseData(i)) {
                int start = (int) (pan.getImage().getHeight() * (1 - getSelectionValue(i)));
                for (int j = start; j < pan.getImage().getHeight(); j++) {
                    if (j > 0 && i > 0) {
                        try {
                            rst.setRGB(posX, posY, pan.getImage().getRGB(i, j));
                        } catch (Exception e) {
                            System.out.println("Org [" + i + "," + j + "], Pos :[" + posX + "," + posY);
                        }
                    }
                    posY++;
                }
                posX++;
            }

        }
    } else if (axis == AXIS_X) {
        int high = 0;
        for (int i = 0; i < pan.getImage().getHeight(); i++) {
            if (getUseData(i)) {
                high++;
            }
        }

        if (rst == null || rst.getHeight() != high || rst.getWidth() != pan.getImage().getWidth()) {
            rst = ImageOperations.getBi(pan.getImage().getWidth(), high);
        } else {
            ImageOperations.setImage(Color.BLACK, rst);
        }
        // This will get the smoothed out aScan from the Dynamic?Range panel
        int posX = 0;
        int posY = 0;

        for (int i = 0; i < pan.getImage().getHeight(); i++) {
            posX = 0;

            if (getUseData(i)) {
                int start = (int) (pan.getImage().getWidth() * (1 - getSelectionValue(i)));
                for (int j = start; j < pan.getImage().getWidth(); j++) {
                    if (j > 0 && i > 0) {
                        try {
                            rst.setRGB(posX, posY, pan.getImage().getRGB(j, i));
                        } catch (Exception e) {
                            System.out.println("Org [" + i + "," + j + "], Pos :[" + posX + "," + posY);
                        }
                    }
                    posX++;
                }
                posY++;
            }

        }
    }

    if (overlayAscan) {
        Graphics2D g = rst.createGraphics();
        g.setColor(Color.cyan);
        GraphicsToolkit.setRenderingQuality(g, GraphicsToolkit.HIGH_QUALITY);
        float max = DataAnalysisToolkit.getMaxf(aScan);
        float min = DataAnalysisToolkit.getMinf(aScan);
        Line2D.Double line = new Line2D.Double();

        GeneralPath path = new GeneralPath();
        for (int i = 0; i < aScan.length; i++) {
            int xP = 0;
            int yP = 0;

            float p1 = ((aScan[i] - min) / (max - min));

            double x = 0;
            double y = 0;

            if (axis == AXIS_Y) {

                y = rst.getHeight() / (double) (aScan.length - 1) * i;
                x = rst.getWidth() * (1 - p1);

            } else if (axis == AXIS_X) {
                x = rst.getWidth() / (double) (aScan.length - 1) * i;
                y = rst.getHeight() * (1 - p1);

            }

            if (i == 0) {
                path.moveTo(x, y);
            } else {
                path.lineTo(x, y);
            }

        }
        g.draw(path);
    }
    return rst;
}

From source file:com.simiacryptus.mindseye.lang.Tensor.java

/**
 * To rgb png buffered png.//from   www  .  j  a v a2s. co m
 *
 * @param redBand   the red band
 * @param greenBand the green band
 * @param blueBand  the blue band
 * @param alphaMask the alphaList mask
 * @return the buffered png
 */
@Nonnull
public BufferedImage toRgbImageAlphaMask(final int redBand, final int greenBand, final int blueBand,
        Tensor alphaMask) {
    assert alphaMask.getDimensions()[0] == getDimensions()[0];
    assert alphaMask.getDimensions()[1] == getDimensions()[1];
    @Nonnull
    final int[] dims = getDimensions();
    @Nonnull
    final BufferedImage img = new BufferedImage(dims[0], dims[1], BufferedImage.TYPE_INT_ARGB);
    for (int x = 0; x < img.getWidth(); x++) {
        for (int y = 0; y < img.getHeight(); y++) {
            final double red = Tensor.bound8bit(this.get(x, y, redBand));
            final double green = Tensor.bound8bit(this.get(x, y, greenBand));
            final double blue = Tensor.bound8bit(this.get(x, y, blueBand));
            final double alpha = Tensor.bound8bit(alphaMask.get(x, y, 0));
            img.setRGB(x, y, (int) (red + ((int) green << 8) + ((int) blue << 16) + ((int) alpha << 24)));
        }
    }
    return img;
}

From source file:Trabalho.HistogramaHSB.java

public ChartPanel criaHistograma() throws IOException {

    //pega a imagem
    BufferedImage img = pegaImagem();
    //w pega a largura da imagem - h pega a altura da imagem
    int w = img.getWidth();
    int h = img.getHeight();
    //d calcula o tamanho da imagem
    int d = (w * h);
    //red, green e blue iro receber os tons de cor antigo da imagem - u vai receber o RGB da cor 
    int red, green, blue, u;
    //retorna rgb no mtodo
    float[] hsb;//from   w  w w .  j  a  va2 s  . co m
    int[] vetH = new int[256];
    int[] vetS = new int[256];
    int[] vetB = new int[256];
    float hue, sat, bri;
    //cAux e oldColor pegam os tons originais da imagem - newColor pega os tons aps o clculo
    Color oldColor;
    Color newColor;

    //for responsvel por substituir os tons antigos pelos novos; percorrem a imagem por largura e altura
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            u = img.getRGB(i, j); //u vai receber o RGB da posio i, j
            oldColor = new Color(u); //oldColor  instanciado e recebe o valor de u
            //cada cor recebe o valor do tom original
            red = oldColor.getRed();
            green = oldColor.getGreen();
            blue = oldColor.getBlue();
            hsb = Color.RGBtoHSB(red, green, blue, null);
            hue = hsb[0];
            sat = hsb[1];
            bri = hsb[2];
            //                System.out.println("RGB [" + red + "," + green + "," + blue + "] converted to HSB [" + hue + "," + sat + "," + bri + "]");

            //                hue = hue * 360;
            //                int convH = Integer.valueOf(new Float(hue).intValue());
            //                vetH[convH]++;
            //
            //                sat = sat * 100;
            //                int convS = Integer.valueOf(new Float(sat).intValue());
            //                vetS[convS]++;
            //
            //                bri = bri * 100;
            //                int convB = Integer.valueOf(new Float(bri).intValue());
            //                vetB[convB]++;

            newColor = new Color(hue, sat, bri);
            //seta o RGB da imagem nas posies i, j pegando os valores da newColor
            img.setRGB(i, j, newColor.getRGB());
        }
    }

    File ouptut = new File("D:\\ProjetosNetBeans\\PDI\\src\\imagens\\5.jpeg");
    ImageIO.write(img, "png", ouptut);

    dataset = new HistogramDataset();
    //pega o RGB

    r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 360);
    r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", r, 101);
    r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", r, 101);

    JFreeChart chart = ChartFactory.createHistogram("Histograma", "Pixels", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //Plota as cores
    XYPlot plot = (XYPlot) chart.getPlot();
    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    //vermelho, verde, azul
    Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true),
            new Color(0x800000ff, true) };
    //desenhando o grfico
    plot.setDrawingSupplier(
            new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:com.hygenics.imaging.ImageCleanup.java

/**
 * Private method that performs the sharpen
 *///from w  w w .  jav a2 s  .co m
public byte[] sharpen(byte[] ibytes, int weight, String format) {
    /*
     * Kernel is |-1|-1|-1| |-1|weight|-1||-1|-1|-1|
     */
    try {
        InputStream is = new ByteArrayInputStream(ibytes);
        BufferedImage proxyimage = ImageIO.read(is);
        // a secondary image for storing new outcomes
        BufferedImage image2 = new BufferedImage(proxyimage.getWidth(), proxyimage.getHeight(),
                BufferedImage.TYPE_BYTE_GRAY);

        // image width and height
        int width = proxyimage.getWidth();
        int height = proxyimage.getHeight();
        int r = 0;
        int g = 0;
        int b = 0;
        Color c = null;
        for (int x = 1; x < width - 1; x++) {
            for (int y = 1; y < height - 1; y++) {
                // sharpen the image using the kernel (center is c5)
                Color c00 = new Color(proxyimage.getRGB(x - 1, y - 1));
                Color c01 = new Color(proxyimage.getRGB(x - 1, y));
                Color c02 = new Color(proxyimage.getRGB(x - 1, y + 1));
                Color c10 = new Color(proxyimage.getRGB(x, y - 1));
                Color c11 = new Color(proxyimage.getRGB(x, y));
                Color c12 = new Color(proxyimage.getRGB(x, y + 1));
                Color c20 = new Color(proxyimage.getRGB(x + 1, y - 1));
                Color c21 = new Color(proxyimage.getRGB(x + 1, y));
                Color c22 = new Color(proxyimage.getRGB(x + 1, y + 1));

                // apply the kernel for r
                r = -c00.getRed() - c01.getRed() - c02.getRed() - c10.getRed() + (weight * c11.getRed())
                        - c12.getRed() - c20.getRed() - c21.getRed() - c22.getRed();

                // apply the kernel for g
                g = c00.getGreen() - c01.getGreen() - c02.getGreen() - c10.getGreen()
                        + (weight * c11.getGreen()) - c12.getGreen() - c20.getGreen() - c21.getGreen()
                        - c22.getGreen();

                // apply the transformation for b
                b = c00.getBlue() - c01.getBlue() - c02.getBlue() - c10.getBlue() + (weight * c11.getBlue())
                        - c12.getBlue() - c20.getBlue() - c21.getBlue() - c22.getBlue();

                // set the new rgb values
                r = Math.min(255, Math.max(0, r));
                g = Math.min(255, Math.max(0, g));
                b = Math.min(255, Math.max(0, b));

                c = new Color(r, g, b);

                // set the new mask colors in the new image
                image2.setRGB(x, y, c.getRGB());

            }
        }

        // add the new values back to the original image
        Color cmask = null;
        Color corig = null;
        for (int x = 1; x < width - 1; x++) {
            for (int y = 1; y < height - 1; y++) {
                // get the 2 colors
                cmask = new Color(image2.getRGB(x, y));
                corig = new Color(proxyimage.getRGB(x, y));

                // add the new values
                r = cmask.getRed() + corig.getRed();
                g = cmask.getGreen() + corig.getGreen();
                b = cmask.getBlue() + corig.getBlue();

                // set the new rgb values
                r = Math.min(255, Math.max(0, r));
                g = Math.min(255, Math.max(0, g));
                b = Math.min(255, Math.max(0, b));

                proxyimage.setRGB(x, y, new Color(r, g, b).getRGB());
            }
        }

        try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
            ImageIO.write(proxyimage, format, baos);
            ibytes = baos.toByteArray();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return ibytes;
}

From source file:tarea1.controlador.java

public BufferedImage generalKernel(float[][] filtro, int n) {

    BufferedImage newBitmap = new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB);

    int i, j, x, y, size = n, newx, newy;
    float sumR, sumG, sumB, a;
    //recorrido de la matriz grande
    for (i = size; i < ancho - size; i++)
        for (j = size; j < alto - size; j++) {
            sumR = 0;//from   w w  w. java2  s. c o  m
            sumG = 0;
            sumB = 0;
            // recorrido del filtro
            for (x = 0; x < n; x++) { // condiciono para q pueda recorrer toda la matriz
                if (x < size) {
                    newx = i - (size - x);
                } else if (x > size) {
                    newx = i + (x - size);
                } else
                    newx = x;
                for (y = 0; y < n; y++) {
                    if (y < size) {
                        newy = j - (size - y);
                    } else if (y > size) {
                        newy = j + (y - size);
                    } else
                        newy = y;

                    if ((newx < ancho) && (newy < alto)) {

                        sumR += new Color(img.getRGB(newx, newy)).getRed() * filtro[x][y];
                        sumG += new Color(img.getRGB(newx, newy)).getGreen() * filtro[x][y];
                        sumB += new Color(img.getRGB(newx, newy)).getBlue() * filtro[x][y];

                    }
                }
            }

            int pixel = (truncate(sumR) << 16) | (truncate(sumG) << 8) | (truncate(sumB));
            newBitmap.setRGB(i, j, pixel);

        } // fin recorrido de matriz

    return newBitmap;
}

From source file:uk.bl.dpt.qa.gui.DissimilarGUIThread.java

/**
 * overlay heatmap on image/*from w w w.  j av  a 2s  .  co  m*/
 */
private void internalOverlayHeatmap() {

    gRightImageSave = imageRight.getImage();

    if (!gHeatmapGenerated) {

        internalBeforeGUIThread();

        //threaded load so GUI doesn't hang
        Task<Integer> task = new Task<Integer>() {

            @Override
            protected Integer call() throws Exception {
                BufferedImage image = SwingFXUtils.fromFXImage(imageRight.getImage(), null);

                if (gHeatmap == null) {
                    //re-generate heatmap (must be on a re-load)
                    try {
                        gHeatmap = Imaging.getBufferedImage(gResults.get(gCurrentRecord).getHeatmapTemp());
                    } catch (IOException | ImageReadException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                for (int y = 0; y < image.getHeight(); y++) {
                    for (int x = 0; x < image.getWidth(); x++) {
                        int rgb = image.getRGB(x, y);

                        Color heatmapColor = new Color(gHeatmap.getRGB((x / DissimilarV2.SSIMWINDOWSIZE),
                                (y / DissimilarV2.SSIMWINDOWSIZE)));
                        int heatmapPixel = heatmapColor.getGreen();//&maxPixelValue;
                        if (heatmapColor.getGreen() != heatmapColor.getBlue()
                                && heatmapColor.getBlue() != heatmapColor.getRed()) {
                            gLogger.error("Heatmap error (should not happen)");
                        }

                        double factor = 1 - (((double) heatmapPixel / 255));

                        Color col = new Color(rgb);
                        int red = (int) (factor * col.getRed());
                        int green = (int) (factor * col.getGreen());
                        int blue = (int) (factor * col.getBlue());

                        if (red < 0)
                            red = 0;
                        if (green < 0)
                            green = 0;
                        if (blue < 0)
                            blue = 0;
                        col = new Color(red, green, blue);

                        image.setRGB(x, y, col.getRGB());
                    }
                }

                gHeatmapImage = SwingFXUtils.toFXImage(image, null);
                gHeatmapGenerated = true;

                Platform.runLater(new Runnable() {
                    //@Override
                    public void run() {
                        imageRight.setImage(gHeatmapImage);
                    }
                });

                internalAfterGUIThread();

                return 1;
            }

        };

        progressIndicator.progressProperty().bind(task.progressProperty());
        Thread loader = new Thread(task);
        loader.setDaemon(true);
        loader.start();

    } else {
        imageRight.setImage(gHeatmapImage);
    }

}