Skip to main content
added 583 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[rPClearAll[bdR, combinePolygonsByColorHolesAllowed]

rPbdR = RegionPlot[RegionUnionBoundaryDiscretizeRegion[RegionUnion @@ #, PlotPoints -> 90, 
    MaxRecursionMeshCellStyle -> 5, PlotStyle{2 -> #2, BoundaryStyle1 -> Thick]Directive[Thick, Gray]}] &;

combinePolygonsByColorHolesAllowed = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]]}, 
        rP[polysbdR[polys, color]] &]], PlotRange -> All, Frame -> False, 
    AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #}, 
   Dividers -> All] &@{gr1, gr2, gr3, gr4}

enter image description hereenter image description here

If holes are not allowed, we need to identify the holes in the region formed by the group of polygons. For this purpose, we BoundaryDiscretizeRegion the RegionUnion of the polygon group and use the (undocumented) function Region`Mesh`FindMeshRegionHoles which returns None if the mesh region does not have any holes and, if it does, a point for each of the holes. For each hole h, we find the polygons that lie on the line from a point in h to nearest point on the outer boundary (obtained using ConnectedMeshComponents) and RegionPlotBoundaryDiscretizeRegion the RegionUnion of resulting partition of the polygon group.

ClearAll[findHoles, combinePolygonsByColorNoHoles]

findHoles = Region`Mesh`FindMeshRegionHoles[
  BoundaryDiscretizeRegion[RegionUnion @@ #]] &;

combinePolygonsByColorNoHoles = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]], 
         bdr = BoundaryDiscretizeRegion[RegionUnion @@ #[[All, 2]]], 
         outerboundary,  lines, partition},
        If[findHoles[polys] === None, rP[polysbdR[polys, color], 
         outerboundary =  First@ConnectedMeshComponents[
            DiscretizeGraphics[MeshPrimitives[bdr, {1, "Boundary"}]]];
         lines =  Rationalize[Line[{#, RegionNearest[outerboundary, #]}] & /@ 
            findHoles[polys], 10^-4]; 
         partition = {Complement[polys, ##], ##} & @@ 
           Table[Select[Rationalize[polys, 10^-4], 
             Head[RegionIntersection[#, ln]] === Line &], {ln , lines}]; 
         Show[rP[FirstShow[bdR[First @ partition, color], 
          rP[#bdR[#, Lighter@color]Lighter @ Lighter @ color] & /@ Rest[partition], 
          PlotRange -> All]]] &]],
     PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #}, 
 Dividers -> All] & @ {gr1, gr2, gr3, gr4}

Showing input graphics (first row), outputs from combinePolygonsByColorHolesAllowed (second row) and outputs from combinePolygonsByColorNoHoles (third row):

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #}, 
 Dividers -> All] & @ {gr1, gr2, gr3, gr4}

enter image description hereenter image description here

gr4a = Graphics[{EdgeForm[Gray], Cases[gr4[[1]], {Red, _}, All]}, 
   ImageSize -> Medium];
gr4b = Replace[combinePolygonsByColorHolesAllowed[gr4],
   
  {_Directive[{___, Directive[__Blue, Blue]___}], _GraphicsGroup_} -> {}, All];
gr4c = Replace[combinePolygonsByColorNoHoles[gr4], 
   {_, Directive[__Directive[{___, Blue | Lighter[Blue]]Lighter[Lighter@Blue], _GraphicsGroup___}], _} -> {}, All];

Row[Show[#, ImageSize -> 250] & /@ {gr4, gr4a, gr4b, gr4c}]

enter image description hereenter image description here

Note: We can also use RegionPlot instead of BoundaryDiscretizeRegion above; that is, we can replace the function rdF above with rP:

rP = RegionPlot[RegionUnion @@ #, PlotPoints -> 90, 
    MaxRecursion -> 5, PlotStyle -> #2, BoundaryStyle -> Thick] &;

The 2D primitives produced by the functions above are FilledCurves if we use rdF; they are Polygons if we use rP.

ClearAll[rP, combinePolygonsByColorHolesAllowed]

rP = RegionPlot[RegionUnion @@ #, PlotPoints -> 90, 
    MaxRecursion -> 5, PlotStyle -> #2, BoundaryStyle -> Thick] &;

combinePolygonsByColorHolesAllowed = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]]}, 
        rP[polys, color]] &]], PlotRange -> All, Frame -> False, 
    AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #}, 
   Dividers -> All] &@{gr1, gr2, gr3, gr4}

enter image description here

If holes are not allowed, we need to identify the holes in the region formed by the group of polygons. For this purpose, we BoundaryDiscretizeRegion the RegionUnion of the polygon group and use the (undocumented) function Region`Mesh`FindMeshRegionHoles which returns None if the mesh region does not have any holes and, if it does, a point for each of the holes. For each hole h, we find the polygons that lie on the line from a point in h to nearest point on the outer boundary (obtained using ConnectedMeshComponents) and RegionPlot the RegionUnion of resulting partition of the polygon group.

ClearAll[findHoles, combinePolygonsByColorNoHoles]

findHoles = Region`Mesh`FindMeshRegionHoles[
  BoundaryDiscretizeRegion[RegionUnion @@ #]] &;

combinePolygonsByColorNoHoles = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]], 
         bdr = BoundaryDiscretizeRegion[RegionUnion @@ #[[All, 2]]], 
         outerboundary,  lines, partition},
        If[findHoles[polys] === None, rP[polys, color], 
         outerboundary =  First@ConnectedMeshComponents[
            DiscretizeGraphics[MeshPrimitives[bdr, {1, "Boundary"}]]];
         lines =  Rationalize[Line[{#, RegionNearest[outerboundary, #]}] & /@ 
            findHoles[polys], 10^-4]; 
         partition = {Complement[polys, ##], ##} & @@ 
           Table[Select[Rationalize[polys, 10^-4], 
             Head[RegionIntersection[#, ln]] === Line &], {ln , lines}]; 
         Show[rP[First @ partition, color], 
          rP[#, Lighter@color] & /@ Rest[partition], 
          PlotRange -> All]]] &]],
     PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #}, 
 Dividers -> All] & @ {gr1, gr2, gr3, gr4}

enter image description here

gr4a = Graphics[{EdgeForm[Gray], Cases[gr4[[1]], {Red, _}, All]}, 
   ImageSize -> Medium];
gr4b = Replace[combinePolygonsByColorHolesAllowed[gr4],
    {_, Directive[__, Blue], _GraphicsGroup} -> {}, All];
gr4c = Replace[combinePolygonsByColorNoHoles[gr4], 
   {_, Directive[__, Blue | Lighter[Blue]], _GraphicsGroup} -> {}, All];

Row[Show[#, ImageSize -> 250] & /@ {gr4, gr4a, gr4b, gr4c}]

enter image description here

ClearAll[bdR, combinePolygonsByColorHolesAllowed]

bdR = BoundaryDiscretizeRegion[RegionUnion @@ #, 
    MeshCellStyle -> {2 -> #2, 1 -> Directive[Thick, Gray]}] &;

combinePolygonsByColorHolesAllowed = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]]}, 
        bdR[polys, color]] &]], PlotRange -> All, Frame -> False, 
    AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #}, 
   Dividers -> All] &@{gr1, gr2, gr3, gr4}

enter image description here

If holes are not allowed, we need to identify the holes in the region formed by the group of polygons. For this purpose, we BoundaryDiscretizeRegion the RegionUnion of the polygon group and use the (undocumented) function Region`Mesh`FindMeshRegionHoles which returns None if the mesh region does not have any holes and, if it does, a point for each of the holes. For each hole h, we find the polygons that lie on the line from a point in h to nearest point on the outer boundary (obtained using ConnectedMeshComponents) and BoundaryDiscretizeRegion the RegionUnion of resulting partition of the polygon group.

ClearAll[findHoles, combinePolygonsByColorNoHoles]

findHoles = Region`Mesh`FindMeshRegionHoles[
  BoundaryDiscretizeRegion[RegionUnion @@ #]] &;

combinePolygonsByColorNoHoles = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]], 
         bdr = BoundaryDiscretizeRegion[RegionUnion @@ #[[All, 2]]], 
         outerboundary,  lines, partition},
        If[findHoles[polys] === None, bdR[polys, color], 
         outerboundary =  First@ConnectedMeshComponents[
            DiscretizeGraphics[MeshPrimitives[bdr, {1, "Boundary"}]]];
         lines =  Rationalize[Line[{#, RegionNearest[outerboundary, #]}] & /@ 
            findHoles[polys], 10^-4]; 
         partition = {Complement[polys, ##], ##} & @@ 
           Table[Select[Rationalize[polys, 10^-4], 
             Head[RegionIntersection[#, ln]] === Line &], {ln , lines}]; 
         Show[bdR[First @ partition, color], 
          bdR[#, Lighter @ Lighter @ color] & /@ Rest[partition], 
          PlotRange -> All]]] &]],
     PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Showing input graphics (first row), outputs from combinePolygonsByColorHolesAllowed (second row) and outputs from combinePolygonsByColorNoHoles (third row):

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #}, 
 Dividers -> All] & @ {gr1, gr2, gr3, gr4}

enter image description here

gr4a = Graphics[{EdgeForm[Gray], Cases[gr4[[1]], {Red, _}, All]}, 
   ImageSize -> Medium];
gr4b = Replace[combinePolygonsByColorHolesAllowed[gr4],  
  {Directive[{___, Blue, ___}], _} -> {}, All];
gr4c = Replace[combinePolygonsByColorNoHoles[gr4],
  {Directive[{___, Blue | Lighter[Lighter@Blue], ___}], _} -> {}, All];

Row[Show[#, ImageSize -> 250] & /@ {gr4, gr4a, gr4b, gr4c}]

enter image description here

Note: We can also use RegionPlot instead of BoundaryDiscretizeRegion above; that is, we can replace the function rdF above with rP:

rP = RegionPlot[RegionUnion @@ #, PlotPoints -> 90, 
    MaxRecursion -> 5, PlotStyle -> #2, BoundaryStyle -> Thick] &;

The 2D primitives produced by the functions above are FilledCurves if we use rdF; they are Polygons if we use rP.

added 558 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Focusing on the red polygons in gr4:

gr4a = Graphics[{EdgeForm[Gray], Cases[gr4[[1]], {Red, _}, All]}, 
   ImageSize -> Medium];
gr4b = Replace[combinePolygonsByColorHolesAllowed[gr4],
   {_, Directive[__, Blue], _GraphicsGroup} -> {}, All];
gr4c = Replace[combinePolygonsByColorNoHoles[gr4], 
   {_, Directive[__, Blue | Lighter[Blue]], _GraphicsGroup} -> {}, All];

Row[Show[#, ImageSize -> 250] & /@ {gr4, gr4a, gr4b, gr4c}]

enter image description here

Focusing on the red polygons in gr4:

gr4a = Graphics[{EdgeForm[Gray], Cases[gr4[[1]], {Red, _}, All]}, 
   ImageSize -> Medium];
gr4b = Replace[combinePolygonsByColorHolesAllowed[gr4],
   {_, Directive[__, Blue], _GraphicsGroup} -> {}, All];
gr4c = Replace[combinePolygonsByColorNoHoles[gr4], 
   {_, Directive[__, Blue | Lighter[Blue]], _GraphicsGroup} -> {}, All];

Row[Show[#, ImageSize -> 250] & /@ {gr4, gr4a, gr4b, gr4c}]

enter image description here

added 433 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[combinePolygonsByColorHolesAllowed]ClearAll[rP, combinePolygonsByColorHolesAllowed]

rP = RegionPlot[RegionUnion @@ #, PlotPoints -> 90, 
    MaxRecursion -> 5, PlotStyle -> #2, BoundaryStyle -> Thick] &;

combinePolygonsByColorHolesAllowed = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]]}, 
        RegionPlot[RegionUnion @@ polys, PlotPoints -> 90, 
         MaxRecursion -> 5, PlotStyle -> colorrP[polys, 
         BoundaryStyle -> Thick]]color]] &]], 
   PlotRange -> All, Frame -> False, 
    AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #}, 
   Dividers -> All] &@{gr1, gr2, gr3, gr4}

Combined regionspolygons cannot have holes:

If holes are not allowed, we need to identify the holes in the region formed by the group of polygons. For this purpose, we BoundaryDiscretizeRegion the RegionUnion of the polygon group and use the (undocumented) function Region`Mesh`FindMeshRegionHoles which returns None if the mesh region does not have any holes and, if it does, a point for each of the holes. For each hole h, we remove fromfind the grouppolygons that lie on the polygon closest toline from a point in h to nearest point on the outer boundary (obtained using ConnectedMeshComponents) and RegionPlot the RegionUnion of remaining polygonsresulting partition of the polygon group.

ClearAll[combinePolygonsByColorNoHoles]ClearAll[findHoles, combinePolygonsByColorNoHoles]

findHoles = Region`Mesh`FindMeshRegionHoles[
  BoundaryDiscretizeRegion[RegionUnion @@ #]] &;

combinePolygonsByColorNoHoles = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]], 
         bdr = BoundaryDiscretizeRegion[RegionUnion @@ #[[All, holes2]]], remove
         outerboundary, keep} lines, partition},
        bdrIf[findHoles[polys] ==== BoundaryDiscretizeRegion[RegionUnionNone, @@rP[polys, polys];color], 
        holes outerboundary = Region`Mesh`FindMeshRegionHoles[bdr]; First@ConnectedMeshComponents[
        remove = If[holes === NoneDiscretizeGraphics[MeshPrimitives[bdr, {}1, "Boundary"}]]];
         lines Function[h,= First@MinimalBy[polys Rationalize[Line[{#, RegionDistance[#RegionNearest[outerboundary, h]#]}] &]]& /@ holes];
         Show[RegionPlot[RegionUnion @@ Complement[polys, remove]findHoles[polys], 
 10^-4];  
         PlotPointspartition ->= 90{Complement[polys, MaxRecursion -> 5##], PlotStyle##} ->& color,@@ 
          BoundaryStyle ->Table[Select[Rationalize[polys, Thick]10^-4], 
         If[remove    Head[RegionIntersection[#, ln]] === {}Line &], Graphics[{}]ln , 
 lines}];  
         RegionPlot[RegionUnionShow[rP[First @@@ removepartition, PlotPoints -> 90color], 
           MaxRecursion -> 5rP[#, PlotStyleLighter@color] ->& color/@ Rest[partition], 
           BoundaryStyle -> Thick]], PlotRange -> All]]All]]] &]], 
     PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHolescombinePolygonsByColorHolesAllowed /@ #}, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #}, 
 Dividers -> All] & @ {gr1, gr2, gr3, gr4}

enter image description hereenter image description here

ClearAll[combinePolygonsByColorHolesAllowed]
combinePolygonsByColorHolesAllowed = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]]}, 
        RegionPlot[RegionUnion @@ polys, PlotPoints -> 90, 
         MaxRecursion -> 5, PlotStyle -> color, 
         BoundaryStyle -> Thick]] &]], 
   PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #}, 
   Dividers -> All] &@{gr1, gr2, gr3, gr4}

Combined regions cannot have holes:

If holes are not allowed, we need to identify the holes in the region formed by the group of polygons. For this purpose, we BoundaryDiscretizeRegion the RegionUnion of the polygon group and use the (undocumented) function Region`Mesh`FindMeshRegionHoles which returns None if the mesh region does not have any holes and a point for each of the holes. For each hole h, we remove from the group the polygon closest to h and RegionPlot the RegionUnion of remaining polygons.

ClearAll[combinePolygonsByColorNoHoles]
combinePolygonsByColorNoHoles = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]], bdr, holes, remove, keep}, 
        bdr = BoundaryDiscretizeRegion[RegionUnion @@ polys]; 
        holes = Region`Mesh`FindMeshRegionHoles[bdr]; 
        remove = If[holes === None, {}, 
          Function[h, First@MinimalBy[polys, RegionDistance[#, h] &]] /@ holes];
         Show[RegionPlot[RegionUnion @@ Complement[polys, remove], 
           PlotPoints -> 90, MaxRecursion -> 5, PlotStyle -> color, 
          BoundaryStyle -> Thick], 
         If[remove === {}, Graphics[{}], 
           RegionPlot[RegionUnion @@ remove, PlotPoints -> 90, 
           MaxRecursion -> 5, PlotStyle -> color, 
           BoundaryStyle -> Thick]], PlotRange -> All]] &]], 
    PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #},
   Dividers -> All] & @ {gr1, gr2, gr3, gr4}

enter image description here

ClearAll[rP, combinePolygonsByColorHolesAllowed]

rP = RegionPlot[RegionUnion @@ #, PlotPoints -> 90, 
    MaxRecursion -> 5, PlotStyle -> #2, BoundaryStyle -> Thick] &;

combinePolygonsByColorHolesAllowed = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]]}, 
        rP[polys, color]] &]], PlotRange -> All, Frame -> False, 
    AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #}, 
   Dividers -> All] &@{gr1, gr2, gr3, gr4}

Combined polygons cannot have holes:

If holes are not allowed, we need to identify the holes in the region formed by the group of polygons. For this purpose, we BoundaryDiscretizeRegion the RegionUnion of the polygon group and use the (undocumented) function Region`Mesh`FindMeshRegionHoles which returns None if the mesh region does not have any holes and, if it does, a point for each of the holes. For each hole h, we find the polygons that lie on the line from a point in h to nearest point on the outer boundary (obtained using ConnectedMeshComponents) and RegionPlot the RegionUnion of resulting partition of the polygon group.

ClearAll[findHoles, combinePolygonsByColorNoHoles]

findHoles = Region`Mesh`FindMeshRegionHoles[
  BoundaryDiscretizeRegion[RegionUnion @@ #]] &;

combinePolygonsByColorNoHoles = Show[Values[
     GroupBy[Cases[#[[1]], {_RGBColor, _Polygon}, All], First, 
      Module[{color = #[[1, 1]], polys = #[[All, 2]], 
         bdr = BoundaryDiscretizeRegion[RegionUnion @@ #[[All, 2]]], 
         outerboundary,  lines, partition},
        If[findHoles[polys] === None, rP[polys, color], 
         outerboundary =  First@ConnectedMeshComponents[
            DiscretizeGraphics[MeshPrimitives[bdr, {1, "Boundary"}]]];
         lines =  Rationalize[Line[{#, RegionNearest[outerboundary, #]}] & /@ 
            findHoles[polys], 10^-4];  
         partition = {Complement[polys, ##], ##} & @@ 
           Table[Select[Rationalize[polys, 10^-4], 
             Head[RegionIntersection[#, ln]] === Line &], {ln , lines}];  
         Show[rP[First @ partition, color], 
          rP[#, Lighter@color] & /@ Rest[partition], 
          PlotRange -> All]]] &]],
     PlotRange -> All, Frame -> False, AspectRatio -> Automatic] &;

Grid[{Style[#, 24] & /@ {"gr1", "gr2", "gr3", "gr4"}, 
    Show[#, ImageSize -> 250] & /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorHolesAllowed /@ #, 
    Show[#, ImageSize -> 250] & /@ combinePolygonsByColorNoHoles /@ #}, 
 Dividers -> All] & @ {gr1, gr2, gr3, gr4}

enter image description here

Post Undeleted by kglr
Post Deleted by kglr
deleted 17 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading