static int bwImage_minOfArea(BWImage bw, Rect r) { if (bw == null) ret 0; int w = r.w, h = r.h; int min = 255; for y to h: for x to w: { int v = bw.getInt(r.x+x, r.y+y); min = min(min, v); } ret min; }