py4sci

Table Of Contents

Previous topic

ga_analyze.py

This Page

block.py

Add blocking layer(s) to an existing image. Use –left <pixel value> and/or –right <pixel value> to paint each side. The –size <pixels> controls the width of the blocking layer. By default, the blocking layer is painted up the entire image. However, you can control the y-values of where the layer starts and stops with –lyi, –lyf, –ryi, and –ryf. Please note that the image origin is in the upper left corner. You may use negative indexing. However, make sure the equivalent (positive) final pixel index is larger than the equivalent (positive) initial pixel index, or nothing with be painted.

usage: block.py [-h] [--size pixels] [--left color] [--right color]
                [--lyi int] [--lyf int] [--ryi int] [--ryf int] [--show]
                ifile.png [ofile.png]

Positional arguments:
ifile input
ofile output
Options:
--size=16 size of blocking layer(s)
--left pixel value (0, 1 == 255) of left side
--right pixel value (0, 1 == 255) of right side
--lyi y-index to start painting at on left side
--lyf y-index to stop painting at on left side
--ryi y-index to start painting at on right side
--ryf y-index to stop painting at on right side
--show=False instead of saving, show result in a matplotlib window

Module author: Adam Gagorik <adam.gagorik@gmail.com>

block.makeBlock(image, left=None, right=None, size=16, lyi=None, lyf=None, ryi=None, ryf=None)[source]

Paint blocking layer(s) over image on left and right side.

Parameters:
  • image (numpy.ndarray) – data
  • left (int) – pixel value to paint on left side (None, 0, 1=255)
  • right (int) – pixel value to paint on right side (None, 0, 1=255)
  • size (int) – width of blocking layer (x-direction)
Returns:

modified image data

Return type:

numpy.ndarray

tristripe.py

make triangle stripes (horizontal triangles)

usage: tristripe.py [-h] [output] [dim.x] [dim.y] [period]

Positional arguments:
ofile output file
width dim.x
height dim.y
period number of triangles along the image

Module author: Geoff Hutchison <geoffh@pitt.edu>

triangle.py

make triangle waves (for fractal roughening)

usage: triangle.py [-h] output dim.x dim.y spacing amplitude period

Positional arguments:
ofile output file
width dim.x
height dim.y
spacing spacing between waves, in pixels
amplitude amplitude of the waves, in pixels
period number of waves along the image

Module author: Geoff Hutchison <geoffh@pitt.edu>

curves.py

make sine curves (for fractal roughening)

usage: curves.py [-h] [dim.x] [dim.y] [spacing] [amplitude] [period] [output]

Positional arguments:
width dim.x
height dim.y
spacing spacing between waves, in pixels
amplitude amplitude of the waves, in pixels
period number of waves along the image
ofile output file

Module author: Geoff Hutchison <geoffh@pitt.edu>

lines.py

make simple lines (for fractal growing)

usage: lines.py [-h] [dim.x] [dim.y] [spacing] [thickness] [output]

Positional arguments:
width dim.x
height dim.y
spacing spacing between waves, in pixels
thickness thickness of the bands, in pixels
ofile output file

Module author: Geoff Hutchison <geoffh@pitt.edu>

iso.py

Generate isotropic two-phase 2D systems using Gaussian noise

usage: iso.py [-h] [--seed int] [dim.x] [dim.y] [sigma] [output]

Positional arguments:
width dim.x
height dim.y
radius radius of Gaussian blur
ofile output file
Options:
--seed random number seed

Module author: Geoff Hutchison <geoffh@pitt.edu>

iso.makeIsotropic(width, height, radius=4)[source]

Generate a 2D isotropic two-phase system using Gaussian random noise. Before thresholding, the random noise is convoluted using a Gaussian blur kernel of sigma “radius”. The resulting data will have a 50:50 mixture as a binary array (0, 1)

Parameters:
  • width (int) – width of the resulting data
  • height (int) – height of the resulting data
  • radius (float) – size of the Gaussian blur kernel
Returns:

morphology data

Return type:

numpy.ndarray

dla.py

diffusion limited aggregation fractal images

usage: dla.py [-h] [spacing]

Positional arguments:
sticky gooeyness

Module author: Geoff Hutchison <geoffh@pitt.edu>

npyToPng.py

convert from *.npy numpy binary files to PNG

usage: npyToPng.py [-h] input [output]

Positional arguments:
ifile input file
ofile output file

Module author: Geoff Hutchison <geoffh@pitt.edu>