*/
public void split(RgbImage rgbImage) {
this.rgbInput = rgbImage;
Vector vecRNotOk = new Vector();
this.vecROk = new Vector();
vecRNotOk.addElement(new Rect(
0,
0,
this.rgbInput.getWidth(),
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);
}