Input |
Amxn matrix of red/green elements obtained after FT-SAP() |
Output |
MER submatrix of |
findMaxRectangleArea ← function () { |
# (1) Initialize. |
maxArea 0; |
area 0; |
# (2) Outer double-for-loop to consider all possible positions for top-left corner. |
for ( in ){ |
for ( in ){ |
# (2.1) With (, ) as top-left, consider all possible bottom-right corners. |
for ( in ){ |
for ( in ){ |
# (2.1.2) See if rectangle(, , , ) is filled. |
Filled ← checkFilled (, , , ); |
# (2.1.3) If so, compute it’s area. |
if (filled){area ← computeArea (, , , )} |
# If the area is largest, adjust maximum and update coordinates. |
if (area > maxArea){ |
maxArea area; |
topLeft← ; |
topLeft← ; |
botRight← ; |
botRight← |
} |
} |
} |
} |
} |
(topLeft, topLeft, botRight, botRight) |
return (list(area = maxArea, rect = )); |
|
computeArea function (, , , ) { |
if ( < ) {return(−1)} |
if ( < ) {return(−1)} |
return (() ()) |
|
checkFilled ← function (, , , ) { |
for ( in ){ |
for ( in ){ |
if ( == 0) {return (FALSE)} |
} |
} |
return (TRUE) |
} |