画像をピクセルに読み込み、一致するピクセル値を確認し、何らかの処理を行い、処理されたピクセルを画像に変換したいと考えています。私は持っている
Pixel Location(582,131)- [Alpha: 255, Red: 243, Green: 88, Blue: 146]
Pixel Location(582,132)- [Alpha: 255, Red: 244, Green: 86, Blue: 145]
Pixel Location(582,133)- [Alpha: 255, Red: 245, Green: 87, Blue: 146]
Pixel Location(582,134)- [Alpha: 255, Red: 248, Green: 90, Blue: 149]
Pixel Location(582,135)- [Alpha: 255, Red: 250, Green: 92, Blue: 151]
Pixel Location(582,136)- [Alpha: 255, Red: 251, Green: 91, Blue: 151]
Pixel Location(582,137)- [Alpha: 255, Red: 248, Green: 88, Blue: 148]
Pixel Location(582,138)- [Alpha: 255, Red: 248, Green: 88, Blue: 148]
これらのピクセル値。これらの値を互いに比較して、一致するピクセルを取得する方法を知りたいと思います。
そして、処理された画像のピクセル値を画像に変換します
public static void pixels(String args) {
BufferedImage image = readImage(args);
printAllARGBDetails(image);
}
public static void printAllARGBDetails(BufferedImage image) {
int width = image.getWidth();
int height = image.getHeight();
System.out.println("Image Dimension: Height-" + height + ", Width-"
+ width);
System.out.println("Total Pixels: " + (height * width));
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
int pixel = image.getRGB(i, j);
System.out.println("Pixel Location(" + i + "," + j + ")- ["
+ getARGBPixelData(pixel) + "]");
}
}
}
public static String getARGBPixelData(int pixel) {
String pixelARGBData = "";
int alpha = (pixel >> 24) & 0x000000FF;
int red = (pixel >> 16) & 0x000000FF;
int green = (pixel >>8 ) & 0x000000FF;
int blue = (pixel) & 0x000000FF;
pixelARGBData = "Alpha: " + alpha + ", " + "Red: " + red + ", "
+ "Green: " + green + ", " + "Blue: " + blue;
return pixelARGBData;
}
public static BufferedImage readImage(String fileLocation)
{
BufferedImage img = null;
try
{
img = ImageIO.read(new File(fileLocation));
}
catch (IOException e)
{
e.printStackTrace();
}
return img;
}