私はデジタル画像処理分野の初心者です。現在、2D配列から画像を取得するためにコーディングしています...これら2つのコードサンプルをダウンロードしました...最初のものを使用しているときは正しい画像を取得していますが、2番目のものを使用しているときは処理されています前作より明るくなったイメージ。
これらのコードの違いと、どのコードを参照すればよいか教えてください...研究論文の結果を得るには、このコードを使用する必要があります...
1)。
public BufferedImage getImage(BufferedImage original, float paddedArray[][], int width, int height) {
BufferedImage img = new BufferedImage(width, height, original.getType());
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
int c = Math.round(paddedArray[i][j]);
int pixel = c << 16 | c << 8 | c;
img.setRGB(i, j, pixel);
}
}
return img;
}
2)。
public BufferedImage getImages(BufferedImage original, float paddedArray[][], int width, int height) {
BufferedImage img = new BufferedImage(width, height, original.getType());
Graphics2D g = (Graphics2D) img.getGraphics();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
int c = Math.round(paddedArray[i][j]);
if (c >= greyRange) {
c = greyRange - 1;
}
g.setColor(new Color(c, c, c));
g.fillRect(i, j, 1, 1);
}
}
return img;
}
私が使用しているこれらのコードは、 と の違いを知りたいだけ
g.setColor(new Color(c, c, c));
です img.setRGB(i, j, pixel);