top of page

RANDOM ART

Personal coding project, responsible for all

Software: Python

This program is using skeleton Python to generate random art images, all users can generate images based on the input of numbers, resolutions, and levels of recursion (figure 0.0).

S22_V705_E3_YuanYachan.0019
S22_V705_E3_YuanYachan.0020
S22_V705_E3_YuanYachan.0017
S22_V705_E3_YuanYachan.0018
S22_V705_E3_YuanYachan.0016
S22_V705_E3_YuanYachan.0015
S22_V705_E3_YuanYachan.0014
S22_V705_E3_YuanYachan.0013
S22_V705_E3_YuanYachan.0012
S22_V705_E3_YuanYachan.0011
colorImage_4
colorImage_0
5
color5
color1
color3
color0
color2

Figure 0.0 Random Art

Technical Breakdown

Step1 Basic settings

  • import PIL, sin, cos, tan, sqrt, pi, radians, random, math, os.

  • Define the evalExpr function that evaluates the string that is sent to it.

  • Define poltIntensity to return a grayscale image of the given function.

  • Define the plotColor function that returns an image constructed from the plotIntensity function (figure 1.0).

code-08.png

Figure 1.0  Basic settings

Step 2 Expressions

Define the buildExpr function to produce random expressions that are suitable for passing to eval Expr, random values will be taken from the list and constitute a range of expressions (figure 2.0).

code-03.png
未标题-2-09.png
未标题-2-10.png

Figure 2.0  Expressions

Step 3 Gray & Color Functions (figure 3.0)

  • Define the makeGray function to generate gray images files named grayImage_0.png, grayImage_1.png

  • Define the makeColor function to generate color images files named colorImage_0.png, colorImage_1.png

code-04.png

Figure 3.0  Gray and Color function

Step 4 High Resolution

Define the recreateImage function that allows users to create images with higher resolution, all expressions are saved in .txt files, users can choose to read these files and generate images with higher resolution (figure 4.0).

code-05.png

Figure 4.0  Recreate images with higher resolution

Step 5 Create Folders & Rename

Once start the program, three folders will be created and save images, images with higher resolutions, and txt files respectively.

If these folders already exist, they will be renamed with an index to get rid of errors, three new folders will be created without an index.

Define the rename function that allows users to rename files in folders created.

code-06.png

Figure 5.0  Create folders and rename images

Step 6 Main

The main function calls other functions inside to generate a bunch of random grayscale and color pictures (figure 6.0).

code-07.png

Figure 6.0  Main function

Workflow

# Description:

#              This program is using skeleton Python to generate random art images
#              The program firstly renames existing folders to get rid of errors and coverage,
#              Then it allows users to generate random gray & color images
#              For each category of images, users should follow three steps:
#              step1: input the number of images
#              step2: input the resolution
#              step3: input the levels of recursion
#              Gray and color images are allowed to recreate with higher resolution
#              Additionally, users are allowed to rename all of the images they created
#
# Date:        May 8, 2022
# Authour:    Yachan Yuan
#                 Adapted by Chris Stone from code by Andrew Farmer
#                 From Nifty Assignments 6/24/2018
#                 Further adapted by Deborah R. Fowler (comments annotated DRF)
#                 4/19/2020 - changed print statements suitable for 3.6 
#
# Input:        Numbers, resolutions, and recursion levels of images
# Output:     Png files of gray and color images with original or higher resolution, txt files

PDF

© 2023 by Yachan. Proudly created with Wix.com

bottom of page