2012-02-17 55 views
0

我的邏輯是積累所有漂浮物檢查每個像素是否包含我獨特的亮度陣列中的亮度[b]。雖然我有浮動問題處理積累所有漂浮物

+0

究竟是什麼問題? – 2012-02-17 18:08:51

回答

1

關閉我的頭頂,我想知道HashMap<Float, Integer>會爲你工作。鍵(Float)將是來自像素的唯一亮度值,並且值(整數)將是具有該亮度的像素的累積計數。

HashMap<Float, Integer> histogram = new HashMap<Float, Integer>(); 
for (int ip = 0; ip < IMAGE_PIXELS; ip++) { 
    float brightness = // get the brightness for this pixel 
    Integer count = histogram.get(brightness); 
    if (count == null) { 
    count = 1; 
    } 
    else { 
    count++; 
    } 
    map.put(brightness, count); 
}