Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Divide an image into an array of colored squares
ResourceFunction["ImageSquareDivide"][img] divides the image img into colored squares. | |
ResourceFunction["ImageSquareDivide"][img,reg] divides the image img into squares, retaining only the squares that are members of the region reg. |
Divide a 2×2 image into squares:
In[1]:= |
|
Out[1]= |
|
Divide an image that is 30 pixels wide into an array of 900 colored square polygons:
In[2]:= |
|
Out[2]= |
|
Include only those squares that are members of a triangular region:
In[3]:= |
|
Out[3]= |
|
Different regions can be specified:
In[4]:= |
|
Out[4]= |
|
The output can be combined with other graphics primitives:
In[5]:= |
|
Out[5]= |
|
The output of the function for an image of width w is a list of w2 colored squares:
In[6]:= |
|
Out[6]= |
|
In[7]:= |
|
Out[7]= |
|
To be useful, regions should be sized to fit within the Rectangle[{-1,-1},{1,1}] to include the full image:
In[8]:= |
|
Out[8]= |
|
Here is an example of a conical mirror anamorphic function operating on the vertices of an image that was divided into squares:
In[9]:= |
|
Out[9]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License