Function Repository Resource:

ImageRadialDivide

Source Notebook

Divide an image into a list of colored polygons centered around the origin

Contributed by: Erik Mahieu

ResourceFunction["ImageRadialDivide"][img]

divides the image img into polygons centered around the origin.

Details and Options

An image of width w is divided into w/2 rings of w polygons each, resulting in w2/2 colored polygons.
Both face and edge colors are taken to be the color of the pixel closest to the centroid of the polygon in the image.
The result is a disk-shaped image where pixels outside of the disk region are discarded.
ResourceFunction["ImageRadialDivide"] is very important for transformations of an image that operate inhomogeneously, that is, differently on different parts of the image. This is the case with anamorphic transformations where the deformation of the original is dependent on the locations of each pixel.

Examples

Basic Examples (1) 

Radially divide an image into a list of colored polygons:

In[1]:=
Graphics[ResourceFunction["ImageRadialDivide"][mandrill]]
Out[1]=

Scope (2) 

The output of the function is a list of colored polygons:

In[2]:=
ird = ResourceFunction["ImageRadialDivide"][mandrill];
In[3]:=
Short[isd, 2]
Out[3]=
In[4]:=
Dimensions[ird]
Out[4]=

The function operates best on circular images such as logos and the like:

In[5]:=
wolf = ImageResize[\!\(\*
GraphicsBox[
TagBox[RasterBox[CompressedData["
1:eJztXQeUFFXWVnKaDpPzDAxRFBiQDAMIEgRJgyxIEBQZyRkcEQQlOT+ISgYR
WSQHEYYkYde0gKgIrLC7YgBUQDAjZt//vjo2W139XoWuV13ds/Wd83mOQ3d1
vVe33rv3vhsq3j+q++BiN91007gy9D/dB05qNXbswPxcD/2fe0aOG5I38sFB
HUaOfzDvwbGN7i9O/1jwJ0tQEgcOHDhw4MCBAwcOHDhw4MCBAwcOKD777DOy
d+9esmDBAjJu3DiSm5tLGjduTKpVq0ZiY2NJ6dKlCdxJcpYqVYrExMSQKlWq
kEaNGpGuXbuSUaNGkfnz55PCwkJy7tw5u4flwAR++OEHsm/fPvLYY4+Rtm3b
Eq/XGyADouhyuUirVq1Ifn4+2bVrF/n222/tHr4DFZw9e5YUFBRIzwzrgFVy
ocXixYuT5s2bk8cff5ycPHnS7mlxQHHhwgUyY8YMUrt2bdvkQovY16ZMmSLJ
sY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rBa6B/QT9SdVqR+mRD/iS
zPbmc/BfQF4QN4m1OdjnwiJ8XLA7a9WqRTp06OBH9PyJj4/n9tIMlohLnDVr
liMfFgJ7yLZt26RaXKzeGeFM9LiDfzFcde6iCugeM2bMIHXq1LFdBnhEDUH0
B0D/ZQf2A88BuiDiF0TvE0YIfaV58+ZSbcyTJ0/aPS0OVICzVOQ9Q0eE3eP1
iquVpqTL5ZJkMz8/X/Lj/K/V3S9qQF1W2K6IR0esZW5urtRzFz1Z4TNl1b2G
jQs7C2dQjRo1Il27diWjRo2S6o6hHjXqpDpw4MCBAwcOHDhw4MCBAwcOHDhw
APw/D1prWQ==
"], {{0, 138.}, {138., 0}}, {0, 255},
ColorFunction->RGBColor],
BoxForm`ImageTag[
       "Byte", ColorSpace -> "RGB", Interleaving -> True, MetaInformation -> <|"XMP" -> <|"BasicSchema" -> <|"CreatorTool" -> "Adobe Photoshop CC 2015.5 (Macintosh)"|>, "MediaManagementSchema" -> <|"DerivedFrom" -> <|"DerivedFrom" -> <|"InstanceID" -> "xmp.iid:724B5939489A11E6B11CEF5EF1A2CCEF", "DocumentID" -> "xmp.did:724B593A489A11E6B11CEF5EF1A2CCEF"|>|>, "DocumentID" -> "xmp.did:724B593C489A11E6B11CEF5EF1A2CCEF", "InstanceID" -> "xmp.iid:724B593B489A11E6B11CEF5EF1A2CCEF"|>, "RightsManagementSchema" -> <|"DerivedFrom" -> <|"DerivedFrom" -> <|"InstanceID" -> "xmp.iid:724B5939489A11E6B11CEF5EF1A2CCEF", "DocumentID" -> "xmp.did:724B593A489A11E6B11CEF5EF1A2CCEF"|>|>|>, "PagedTextSchema" -> <|"DerivedFrom" -> <|"DerivedFrom" -> <|"InstanceID" -> "xmp.iid:724B5939489A11E6B11CEF5EF1A2CCEF", "DocumentID" -> "xmp.did:724B593A489A11E6B11CEF5EF1A2CCEF"|>|>|>|>|>],
Selectable->False],
DefaultBaseStyle->"ImageGraphics",
ImageSizeRaw->{138., 138.},
PlotRange->{{0, 138.}, {0, 138.}}]\), 50];
In[6]:=
Graphics[ResourceFunction["ImageRadialDivide"][wolf]]
Out[6]=

Neat Examples (1) 

Here is an example of a conical mirror anamorphic function operating on the vertices of an image that was divided into squares:

In[7]:=
ana[{yi_, zi_}, \[Phi]_] := Re /@ {yi (3 - 2 yi^2 + 2 Sqrt[1 - yi^2] zi Cot[\[Phi]]), 2 (1 - yi^2)^(3/2) + (zi - 2 yi^2 zi) Cot[\[Phi]]}
In[8]:=
Graphics[MapAt[ana[#, 50 \[Degree]] &, ResourceFunction["ImageRadialDivide"][mandrill], {All, -1, -1, All}]]
Out[8]=

Publisher

Erik Mahieu

Version History

  • 1.0.0 – 09 November 2020

Related Resources

License Information