What is wrong in this code .... !

Hi

I used the code below to raed a histogram image stored in an two dim. array to detmine the peaks of the histogram or in other words (the tallest rows in the array) but I faced a wrong results. Why ? I couldnt figure out why . Help me plz .

Thanks in advance

List tallestList =new ArrayList();

int numColoredRows = 0;

int tempTallestIndex = -1;

int tempTallestNum = 0;

List listA =new ArrayList();

List listB =new ArrayList();

listA.add(new Integer (0));

for(int rowIndex = 0 ; rowIndex < twoDim.length; rowIndex++){

// The current row to examine.

int[] row = twoDim[rowIndex];

// Count the number of (concatenated) colored pixels

// from the current row.

int numColoredPixels = numColoredPixelsInRow(row);

if(numColoredPixels > 0) numColoredRows++;

if(numColoredPixels > tempTallestNum)

{

tempTallestNum = numColoredPixels;

tempTallestIndex = rowIndex;

}

if(numColoredRows > 1 && (rowIndex == twoDim.length-1 ||

numColoredPixels == 0))

{

tallestList.add(new Integer(tempTallestIndex));

// listA.add(new Integer(tempTallestIndex));

}

if(numColoredPixels == 0)

{

numColoredRows = 0;

tempTallestIndex = -1;

tempTallestNum = 0;

}

}

System.out.println("List tallestList: " + tallestList);

[2327 byte] By [Amoonaha] at [2007-10-3 8:28:13]
# 1
For example .. this histogram http://nomatterwhat.jeeran.com/Hhist.jpghas three peaks .. but the code gives me this list of tallest rows [93, 285]
Amoonaha at 2007-7-15 3:34:55 > top of Java-index,Java Essentials,Java Programming...
# 2

/**

* @paramthe column as an array of int's.

* @return the number of non-zero pixels

*/

public static int numColoredPixelsInColumn(int[] column) {

int count = 0; int startPoint = 5; //(column.length)/4;

for(int i = startPoint; i < column.length; i++) {

System.out.print("Column 0: " + column[i]);

if(column[i] != -1) count++;

}

return count;

}

Amoonaha at 2007-7-15 3:34:55 > top of Java-index,Java Essentials,Java Programming...
# 3
Nothing ... ?
Amoonaha at 2007-7-15 3:34:55 > top of Java-index,Java Essentials,Java Programming...