Rectangle Islands (Rectangle Grids)

Auxs

T1={{2,1,2},{1,1,1},{2,2,2},{1,1,1},{3,1,3}};

InsideIsl[ {x_,y_},{a_,b_}]=1≤x≤a∧1≤y≤b;

FindMinHeight[Isl_]:=Min[Flatten[Isl]]

TakeValidNeighbours[Isl_,cell_]:=Module[{l={{cell[[1]]-1,cell[[2]]-1},{cell[[1]],cell[[2]]-1},{cell[[1]]+1,cell[[2]]-1},{cell[[1]]-1,cell[[2]]},{cell[[1]]+1,cell[[2]]},{cell[[1]]-1,cell[[2]]+1},{cell[[1]],cell[[2]]+1},{cell[[1]]+1,cell[[2]]+1} }},Select[Select[l,InsideIsl[#,Dimensions[Isl]]&],Isl[[Sequence@@#]]>FindMinHeight[Isl]&]]

FindMaxIsl1[Isl_,cell_]:=Module[{imi1,imi2,ima1,ima2,mcl={},cl={cell},cc},If[Isl[[Sequence@@cell]]==FindMinHeight[Isl],Return[{}]];While[cl=!={},cc=First[cl];AppendTo[mcl,cc];cl=Drop[cl,1];cl=Complement[Union[Join[cl,TakeValidNeighbours[Isl,cc]]],mcl]];imi1=Min[mcl[[All,1]]];imi2=Min[mcl[[All,2]]];ima1=Max[mcl[[All,1]]];ima2=Max[mcl[[All,2]]];If[Length[mcl]==(ima2-imi2+1)(ima1-imi1+1),Sort[mcl],{}]]

MaxIslandColoring[T_,pt_]:=Module[{},{r,c}=Dimensions[T];{Automatic,Automatic,Flatten[Table[{j,k}->If[InsideIsl[{r+1-Ceiling[r pt[[2]]],Floor[c pt[[1]]]+1},{r,c}]∧MemberQ[FindMaxIsl1[T,{r+1-Ceiling[r pt[[2]]],Floor[c pt[[1]]]+1}],{j,k},2],Cyan,White],{j,r},{k,c}]]}]

Experiments

Manipulate[Grid[T1,Background->MaxIslandColoring[T1,pt],Dividers->All],{{pt,{0,0}},Locator,AutoAction->False},FrameLabel->{"","","Maximal Islands",""},SaveDefinitions->True]