picture histogram複数の画像ヒストグラムと処理を比較する
私は処理言語がとても新しいです。私は画像比較ツールを作成しようとしています。
アイデアは、写真のヒストグラムを取得することです(下のスクリーンショットを参照してください、サイズは600x400です)。次に類似の写真のヒストグラム10個(全サイズ600x400)と比較されます。ヒストグラムは、左に表示される純粋な黒の値の数および右の純粋な白の値の数を用いて、グレーレベルの頻度分布を示す。
最終的には、「勝った」画像(最も類似したヒストグラムを持つ画像)を取得する必要があります。
以下に、処理チュートリアルの例と同様に画像ヒストグラムのコードを示します。
ヒストグラムを作成してからif文を作成するために、他の10枚の画像に対してPImage []
を作成しましたが、どのようにコード化するのか分かりません。
今後の進め方や見た目についてのヒントはありますか?私は同様の投稿を見つけることができませんでした。
ご質問ありがとうございました。ご質問は非常に基本的です!
size(600, 400);
// Load an image from the data directory
// Load a different image by modifying the comments
PImage img = loadImage("image4.jpg");
image(img, 0, 0);
int[] hist = new int[256];
// Calculate the histogram
for (int i = 0; i < img.width; i++) {
for (int j = 0; j < img.height; j++) {
int bright = int(brightness(get(i, j)));
hist[bright]++;
}
}
// Find the largest value in the histogram
int histMax = max(hist);
stroke(255);
// Draw half of the histogram (skip every second value)
for (int i = 0; i < img.width; i += 2) {
// Map i (from 0..img.width) to a location in the histogram (0..255)
int which = int(map(i, 0, img.width, 0, 255));
// Convert the histogram value to a location between
// the bottom and the top of the picture
int y = int(map(hist[which], 0, histMax, img.height, 0));
line(i, img.height, i, y);
}
ありがとうございました。 –
@ julia_3010これを受け入れるようにして、これ以上の回答は必要ないと誰も知らないようにしてください。 – Piglet
ありがとう、ちょうどそれを受け入れた –