BufferedImage draw Borders Black And White - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Paint

Description

BufferedImage draw Borders Black And White

Demo Code


//package com.java2s;
import java.awt.Color;
import java.awt.image.BufferedImage;

public class Main {
    public static void drawBordersBlackAndWhite(BufferedImage imageBorders,
            int[][] differentialIntMatrix, int width, int height,
            int threshold) {
        for (int i = 0; i < width - 1; i++) {
            for (int j = 0; j < height - 1; j++) {

                boolean isBorder = differentialIntMatrix[i][j] > threshold ? true
                        : false;//w  ww.  j a v  a  2 s  .c  o  m
                if (isBorder) {
                    imageBorders.setRGB(i, j, Color.black.getRGB());
                } else {
                    imageBorders.setRGB(i, j, Color.white.getRGB());
                }

            }
        }
    }
}

Related Tutorials