Find number of rectangles in a 2D byte array
GolfScript, 107 characters
.n?):L;'1'/{,}%{1$+)}*;][]\{:A{{+}+[1L.~)-1]%&amp;}+1$\,.@^\[[[A]]+{|}*]+}/{.{L%}{%$..&amp;1$,1$,/*$=}:C~\{L/}C&amp;},,

The input must be given on STDIN.
Examples:
11
01
-
0

111
111
-
1

100
001
001
-
2

11100
10101
11100
-
1

101
010
101
-
5