this.rgbInput.getHeight()));
while (!vecRNotOk.isEmpty()) {
Rect r = (Rect) vecRNotOk.elementAt(0);
vecRNotOk.removeElementAt(0);
if (r.getHeight() >= 2 && r.getWidth() >= 2) {
MeanVar nVar = computeVariance(r);
if (nVar.getRVar()>this.nRVar ||
nVar.getGVar()>this.nGVar ||
nVar.getB()>this.nBVar) {
// split horizontally or vertically, whichever
// is longer
if (r.getWidth() >= r.getHeight()) {
// split horizontally
int nHalfWidth = r.getWidth()/2;
Rect rNew =
new Rect(r.getLeft(),
r.getTop(),
nHalfWidth,
r.getHeight());
vecRNotOk.addElement(rNew);
rNew = new Rect(r.getLeft()+nHalfWidth,
r.getTop(),
r.getWidth() - nHalfWidth,
r.getHeight());
vecRNotOk.addElement(rNew);
} else {
// split vertically
int nHalfHeight = r.getHeight()/2;
Rect rNew = new Rect(r.getLeft(),
r.getTop(),
r.getWidth(),
nHalfHeight);
vecRNotOk.addElement(rNew);
rNew = new Rect(r.getLeft(),
r.getTop()+nHalfHeight,
r.getWidth(),
r.getHeight() - nHalfHeight);
vecRNotOk.addElement(rNew);
}
} else {
RgbRegion reg = new RgbRegion(r, nVar);
this.vecROk.addElement(reg);
}
} else {
// region too small, stop splitting
MeanVar nVar = computeVariance(r);
RgbRegion reg = new RgbRegion(r, nVar);
this.vecROk.addElement(reg);
}
}
}