/**
   * Returns the maximum value inside this pixel area for the given raster. You can optionally get
   * the position of the maximum value by passing a reference to a vector. If this vector is null it
   * will be ignored.
   *
   * @param theRaster the raster to check for the maximum value
   * @param thePosition reference to store the position of the maximum
   * @return maximum value inside the pixel row
   */
  public float max(CCPixelRaster theRaster, CCVector2i thePosition) {
    float myMax = 0;
    int myCountMaxs = 0;

    float myX = 0;
    float myY = 0;

    CCVector2i myTemp = new CCVector2i();

    int counter = 0;

    for (CCConnectedPixelRow myRow : _myConnectedPixelRows) {
      counter++;
      float value = myRow.max(theRaster, myTemp);

      if (value > myMax) {
        myMax = value;

        myCountMaxs = 1;
        myX = myTemp.x();
        myY = myTemp.y();
        if (thePosition != null) thePosition.set(myTemp);
      } else if (value == myMax) {
        myCountMaxs++;
        myX += myTemp.x();
        myY += myTemp.y();
      }
    }

    if (thePosition != null) thePosition.set((int) (myX / myCountMaxs), (int) (myY / myCountMaxs));
    return myMax;
  }