static QuadTreeBitMatrix bitMatrixToQuadTree(BitMatrix m) { int w = m.getWidth(), h = m.getHeight(); QuadTreeBitMatrix qt = new(w, h); for y to h: for x to w: if (m.get(x, y)) qt.set(x, y); ret qt; }