Module author: Geoff Hutchison <geoffh@pitt.edu>
Makes sure object is an ndarray with len(shape) = 3
Parameters: | obj – arbitrary python object |
---|---|
Returns: | numpy.ndarray |
Makes sure object is an ndarray with len(shape) = 2
Parameters: | obj – arbitrary python object |
---|---|
Returns: | numpy.ndarray |
Loads data from image file (png, jpg, etc).
Parameters: | |
---|---|
Returns: |
Loads data from numpy file (npy).
Parameters: | |
---|---|
Returns: |
Generate a mathematical morphology structure kernel (i.e., a circle/disk) of radius n
Parameters: | n (int) – radius of disk |
---|---|
Returns: | structuring kernel |
Return type: | numpy.ndarray |
See also
Generate a mathematical morphology structure kernel (i.e., a square) of size n
Parameters: | n (int) – radius of disk |
---|---|
Returns: | structuring kernel |
Return type: | numpy.ndarray |
See also
Todo
comment function
Parameters: |
|
---|---|
Returns: | list of particle counts at each size |
Return type: | list[int] |
Calculate the average domain size for the image (for the “true” phase). Really, it returns the avg/std (over labeled regions) of the distance to a boundary. The distance average is over the “max of mins”. This means, first a minimum distance is calculated to the boundary for each region. Then the max of those distances is found for each region. Finally, the average of those max’s is taken. Full output returns the avg, the std, a labeled version of the image, the number of unique regions, the min-distance matrix, and the max-distance list.
Parameters: |
|
---|---|
Returns: | mean and standard deviation of domain sizes |
Return type: | tuple(int) |
Calculate the fractal dimension of the edges of the supplied image.
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | slope of best-fit line of the log-log plot |
Return type: | int |
See also
Calculate the interfacial area (length for 2D images) between the phases. Faster version of interface_size_old() that works on any dimension. Tested for 1D, 2D, and 3D.
Parameters: |
|
---|---|
Returns: | total length of interface (in pixels) |
Return type: | int |
..seealso: test_interface_size(), interface_size_old()
Calculate the connectivity of the two phases to the side electrodes and the average “transfer distance” (i.e., the shortest distance a charge carrier must travel to be collected at an electrode).
The transfer distances and connectivity fractions are calculated using a breadth-first search from the electrodes left = white phase, right = black phase.
Parameters: |
|
---|---|
Returns: | average transfer distance and connectivity fraction (phase 1 and then phase 2) |
Return type: | tuple(float) |
Count the distribution of bottlenecks
Parameters: | image (numpy.ndarray) – data (binary) |
---|---|
Returns: | count of bottlenecks of size 4 and size 2 |
Return type: | tuple(int) |
Modify one or two images with various “mutation” options. - Blend and re-threshold two images - Gaussian Blur - Uniform Blur (preserves edges) - Shrink and tile - Enlarge and tile - Add pepper to a particular phase - Roughen edges - Grow one phase using diffusion-limited growth (fractal noise)
usage: modify.py [-h] [--type type] input1 [input2]
ifile1 | input file #1 |
ifile2 | input file #2 |
--type | mutation type |
Module author: Geoff Hutchison <geoffh@pitt.edu>
Threshold an image to return a binary numpy.ndarray with a 50:50 mix of two phases.
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
Mix two images, blur and threshold
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Blur an image with a Gaussian kernel of supplied radius
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Blur an image with a Uniform blur kernel of supplied radius (the uniform filter better preserves edges/boundaries
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Randomly shrink an image using different x and y scales. Re-tile and slice the image to ensure the dimensions remain the same.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Randomly enlarge an image using different x and y scales. Slice the image to ensure the dimensions remain the same.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Add pepper to image.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Roughen the edges of the two phases. Use a binary-closing and dilation to find the edge between phases (ignoring pepper defects) and then flip the phase of a fraction of the resulting edge sites.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Grow points into a minority phase using diffusion-limited fractal growth. The result will ensure 50:50 mixtures and by default will determine the minority phase automatically, but both could be specified.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Invert the phases (i.e., black -> white, white->black)
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
What random noise should be doing?
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Grow edges of white phase.
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
Erode edges of white phase.
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
Open up white phase so that struct fits without overlapping black phase.
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
Open up black phase so that struct fits without overlapping white phase.
Parameters: | image (numpy.ndarray) – data |
---|---|
Returns: | modified image data |
Return type: | numpy.ndarray |
Deconstruct image into skeleton and distance mask. Alter the skeleton and/or distance mask and then reconstruct a new morphology. With no altering functions passed, this function will not modify the image.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Take fourier transform, alter it, and reconstruct image. For some reason this is shifting the origin by 1 pixel after reconstruction, which should not happen.
Parameters: |
|
---|---|
Returns: | modified image data |
Return type: |
Random float in range.
Parameters: | |
---|---|
Returns: | values |
Return type: | float |
1D Gaussian.
Parameters: |
|
---|---|
Returns: | values |
Return type: | float |
2D Gaussian.
Parameters: |
|
---|---|
Returns: | values |
Return type: | float |
Draw a bunch of Gaussians of random sigma along skeleton of image.
Parameters: |
|
---|
Genetic algorithm design of 2D morphologies.
usage: ga.py [-h] [--rescore] [--silent] directory [population] [generations] [children] [mutability] [diversity]
dir | initial directory |
population | size of population |
generations | # of generations |
children | # of children to create each generation |
mutability | # of items to mutate each generation |
diversity | percent of pixels that need to differ |
--rescore=False | |
rescore initial files | |
--silent=False | set logging level to ERROR only |
Module author: Geoff Hutchison <geoffh@pitt.edu>
Score individual image files for the genetic algorithm. The idea is to derive predictive factors for the langmuir performance (i.e., max power) based on the connectivity, phase fractions, domain sizes, etc. The scoring function should be based on multivariate fits from a database of existing simulations. To ensure good results, use robust regression techniques and cross-validate the best-fit.
Parameters: | filename (str) – image file name |
---|
:return score (ideally as an estimated maximum power in W/(m^2)) :rtype float
Score a list of files in parallel using the supplied processing pool
Parameters: |
|
---|---|
Returns: | list of tuples (score, filename) |
Return type: | list of tuple |