2012-02-17 80 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); 
}