Message Boards Message Boards

1
|
12476 Views
|
7 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Partition images into hexagons ?

Posted 10 years ago

I am trying to partition images into hexagons. Is that possible in Mathematica?

7 Replies

Thanks for you reply

POSTED BY: André Dauphiné

This model is the theory of Christaller or Lösch to explain hierarchy of cities An image illustrating these theories: enter image description here

POSTED BY: André Dauphiné

If one can build such a figure from polygons in Mathematica, then it is easy to use the same procedure - just this simple line will make texture mapping (partitioning):

Cases[ ..... , Polygon[p_, ___] :> Polygon[p, VertexTextureCoordinates -> p], Infinity]

no matter what complex arrangement of polygons we deal with.

POSTED BY: Vitaliy Kaurov

The solutions proposed by Vitally are very interesting A question : We have only two level of hexagones. Do you have a simple solution for 3, 4 or 5 levels?

POSTED BY: André Dauphiné

I am not sure what "3, 4 or 5 levels" would look like - is there a link to a picture somewhere?

POSTED BY: Vitaliy Kaurov

It is a bit not clear what you mean. Say you mean a simple overlap...

h[x_, y_] := Polygon[Table[.1 {Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y}, {k, 6}]]
hex = Graphics[{EdgeForm[Directive[Black, Thick]], FaceForm[], LightBlue, 
   Table[h[3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, 3}, {j, 10}]},  ImageSize -> 512]

enter image description here

ImageMultiply[{ExampleData[{"TestImage", "Lena"}], Rasterize@hex}]

enter image description here

Or maybe you'd like something (adopted from here ) fancier...

Manipulate[SeedRandom[1];
 Graphics[{EdgeForm[Black], Texture[ExampleData[{"TestImage", "Lena"}]], 
   GeometricTransformation[#, 
      Composition[TranslationTransform@RandomReal[.1 s {-1, 1}, 2], 
       RotationTransform[s RandomReal[{-Pi, Pi}], Mean@First[#]]]] & /@
     Cases[Normal@hex, 
     Polygon[p_, ___] :> Polygon[p, VertexTextureCoordinates -> p], Infinity]}], {s, 0, 1}]

enter image description here

POSTED BY: Vitaliy Kaurov

The basic Image format is rectangular. ImagePartition only partitions Images into rectangular portions. You could however presumably make use of ImagePartition with various sizes and offsets to create a set of square crops at hexagonal grid points. Then these could be masked to remove the areas outside of the hexagonal region in each--leaving those areas transparent. This then could be used as an in-effect hexagonal partition. Of course the devil is in the details...

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract