2017-01-07 14 views
0

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); 
    } 

答えて

1

問題が処理の実装であるか、ヒストグラムの比較方法がわからない場合は、不明です。私はそれが残りの部分がかなりまっすぐであるので比較であると仮定します。すべての候補者の類似度を計算し、勝者を選ぶ。

は、ヒストグラム比較のためにウェブを検索し、他の人の間で、あなたは見つける: http://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.html

OpenCVのは、ヒストグラムの類似性のための4つの施策を実施しています。

相関

enter image description here

ここenter image description here及びNは、ヒストグラムのビンの数

又は

カイ二乗

あります

enter image description here

または

交差点

enter image description here

または

バッタチャリヤ、距離

enter image description here

あなたは、これらの手段を使用することができますが、私はあなたにも他の何かを見つけることができます確信しています。

+0

ありがとうございました。 –

+0

@ julia_3010これを受け入れるようにして、これ以上の回答は必要ないと誰も知らないようにしてください。 – Piglet

+0

ありがとう、ちょうどそれを受け入れた –

関連する問題