volosati / Mandala-Generation

A Mandala Pattern Dataset built by mining the internet, creating patterns on Wolfram Mathematica and Python, and generating patterns using WGAN-div.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mandala Generation

A Mandala Pattern Dataset built by mining the internet, creating patterns on Wolfram Mathematica and Python, and generating patterns using WGAN-div.

Web mining

To mine for images, we mainly used Google Images and Instagram. We used Python libraries to mine for around 16,000 images from both the sources and after clearing through all the junk data, we finally collected around 6,305 clear mandala patterns.

Code:

  • data from google.ipynb
  • data from insta.ipynb
  • google_images_download.ipynb

Symmetric Pattern Generation Application

Wolfram Mathematica

We can generate Mandala designs using mathematical functions in Wolfram Mathematia with the following steps as depicted in Figure 3:

  • Get a set of line segments.
  • Get endpoints of the line segments, and use connecting functions like Polygon, Lines, Bezier Curves to randomly connect points and get a half mandala segment.
  • In order to get one segment, take mirror image over x-axis of the previous segment.
  • A whole mandala pattern can be created by rotating the segment and replicating it.

alt text

Wolfram Mathematica Mandala creation process

By changing the parameters like number of line segments to get points from (numbreaks), radius (numlength), angle of a segment (numrotation) (angle = Pi/numrotation) and connecting function (connectionfunc) we can get new mandala patterns. The application is also currently deployed on the web link https://www.wolframcloud.com/obj/a1eb70b1-2f4f-4270-9cf6-b93747d4b276.

Code:

  • wolfram_mandala.nb; Mathematica notebook to create mandala designs

Python

Generation of patterns on Python is done in two broad ways; automatically and manually. For both the methods, the process is as follows:

  • The process begins with the generation of a scribble. This can be a hand-drawn scribble (drawn by the user using Tkinter canvas), or it can be automatically generated by the computer (randomly placed circles, rectangles and lines).
  • Once the scribble is formed, it is then divided into sub sections of 200x200 dimensions, which are each used as the beginning of two mandala patterns.
  • The sub image extracted is flipped across the diagonal axis, and then flipped across the x and y axis to form a symmetric mandala with 8 cross sections.
  • For the second mandala the sub image is simply flipped across the x and y axis to form a symmetric mandala with 4 cross sections.
  • A circle mask is applied on both the images, so that the final resulting mandala is circular and more symmetric looking in shape.
  • Once all sub images are used, the original scribble is then flipped across the x and y axis to form more unique mandalas.

alt text

Python Mandala creation process

Another user friendly custom mandala drawing tool is the section-wise drawing application, which allows the user to draw a specific section, which is then replicated exactly, forming a mandala custom to the user’s wishes. This is mainly an application to draw specific mandala patterns catering to the user’s needs.

Code:

  • auto-pattern.py; automatic scribble
  • manual.py; manual scribble
  • eighth.py; custom mandala drawing tool

WGAN-div

Source: Wu, Jiqing, et al. "Wasserstein divergence for gans." Proceedings of the European Conference on Computer Vision (ECCV). 2018. We first fed the WGAN-div with only the data generated using Wolfram and Python, and while it formed stunning symmetric patterns, they were all in greyscale due to the source images being in greyscale. Hence we then added in the mined colorful images, which resulted in colorful mandala patterns that were also symmetric.

About

A Mandala Pattern Dataset built by mining the internet, creating patterns on Wolfram Mathematica and Python, and generating patterns using WGAN-div.


Languages

Language:Jupyter Notebook 95.7%Language:Mathematica 3.4%Language:Python 0.9%