Package image
Contains some utility methods for handling images.
More...
Detailed Description
Contains some utility methods for handling images.
Function Documentation
def image.add_grey_grids |
( |
|
grids, |
|
|
|
factors = None | |
|
) |
| | |
Adds weighted values of grids together.
Definition at line 316 of file image.py.
def image.add_grid |
( |
|
grid, |
|
|
|
summand | |
|
) |
| | |
Adss a constant to all values of a grid.
Returns the result as a new grid.
Definition at line 229 of file image.py.
def image.blend |
( |
|
grid1, |
|
|
|
grid2, |
|
|
|
blend_image | |
|
) |
| | |
def image.channels_to_rgb_grid |
( |
|
grids |
) |
|
Converts a list of three grids into an RGB grid.
The three grids each represents a color channel, and should contain floating point values between 0 and 1. The resulting grid contains tuples, each with four elements, between 0 and 1, representing RGBA. Alpha is laways set to 1.
Definition at line 61 of file image.py.
An extremely simple edge detection algorithm.
Definition at line 128 of file image.py.
def image.entropy |
( |
|
grid, |
|
|
|
n | |
|
) |
| | |
Returns a grid that represents the entropy around the pixels in a given grid.
The entropy around a pixel is measured as the sum of the absolute differences between that pixel's channels and the surrounding pixels' corresponding channels.
- Parameters:
-
| grid | The grid to measure |
| n | Determines the size of the window around eaxh pixel to use. If n is 1, the window size is 3by3, if it is 2, the window size is 5 by 5. |
Definition at line 245 of file image.py.
def image.float_sequence |
( |
|
seq |
) |
|
Converts a sequence of integers (ranged 0 to 255) to floats (ranged 0 to 1).
Definition at line 22 of file image.py.
def image.greyscale_grid_to_rgb_grid |
( |
|
grid, |
|
|
|
color | |
|
) |
| | |
Converts a greyscale grid (every cell contains a float [0.
.1]) into an RGB grid. The given color is multiplied by the value in the grid to give the value of the corresponding cell in the new grid.
Definition at line 108 of file image.py.
def image.grid_to_rgb_image |
( |
|
grid, |
|
|
|
fname | |
|
) |
| | |
Converts a 2D grid to an image on the disk.
The grid must contain float values (ranged 0 to 1).
Definition at line 32 of file image.py.
def image.index_grid_to_rgb_grid |
( |
|
grid, |
|
|
|
pallet | |
|
) |
| | |
Take a grid containing non-negative integers, and makes a new grid with elements from the pallet.
If the old grid had an element 3 in a cell, then the element in the corresponding cell in the new grid will hold the value of the 4th element of the pallet.
Definition at line 87 of file image.py.
def image.int_sequence |
( |
|
seq |
) |
|
Converts a sequence of floats (ranged 0 to 1) to integers (ranged 0 to 155).
Definition at line 13 of file image.py.
def image.integrate |
( |
|
grid |
) |
|
Calculates the integral grid of a grid.
Definition at line 329 of file image.py.
def image.integrate_vertically |
( |
|
grid |
) |
|
def image.mix_color |
( |
|
color0, |
|
|
|
color1, |
|
|
|
t | |
|
) |
| | |
Interpolates a color between two given colors.
If t is set to 0, the returned grey is the same as col1. If t is set to 1, the returned grey is the same as col2.
Definition at line 293 of file image.py.
def image.mix_grey |
( |
|
col1, |
|
|
|
col2, |
|
|
|
t | |
|
) |
| | |
Interpolates a grey between two given greys.
If t is set to 0, the returned grey is the same as col1. If t is set to 1, the returned grey is the same as col2.
Definition at line 286 of file image.py.
def image.multiply_grid |
( |
|
grid, |
|
|
|
factor | |
|
) |
| | |
Multiplies all values of a grid with a constant.
Returns the result as a new grid.
Definition at line 220 of file image.py.
def image.normalize |
( |
|
grid |
) |
|
Returns a grid in which the colours have been normalised.
Colours are adjusted so that the returned grid has a minimum color component of 0, and a maximum component of 1.
Definition at line 151 of file image.py.
def image.normalize_grey |
( |
|
grid |
) |
|
Returns a grid where all values have been normalised between 0 and 1.
Definition at line 180 of file image.py.
def image.rgb_grid_to_greyscale_grid |
( |
|
grid |
) |
|
def image.rgb_image_to_grid |
( |
|
fname |
) |
|
Loads an image from disk into a grid.
Definition at line 72 of file image.py.
def image.rgb_image_to_image_grid_channels |
( |
|
fname |
) |
|
Loads an image from disk, and returns a tuplet of grids, one for each channel.
The alpha channel is ignored.
Definition at line 43 of file image.py.
def image.saturate |
( |
|
grid |
) |
|
Clamps all values in a grid between 0 and 1.
Definition at line 203 of file image.py.
def image.threshold |
( |
|
grid, |
|
|
|
value | |
|
) |
| | |
def image.tile |
( |
|
grid, |
|
|
|
m, |
|
|
|
n | |
|
) |
| | |
Returns a new grid, containing m by n copies of the given grid.
Definition at line 303 of file image.py.
def image.transpose |
( |
|
grid |
) |
|
def image.white_noise |
( |
|
dims, |
|
|
|
period = 1 | |
|
) |
| | |
Returns a grid containing white noise in the range [0 1].
- Parameters:
-
| dims | The dimensions of the grid to return (as a xy-tuple). |
| period | This is the period of different noise samples. For example, if the period is 2, then 2-by-2 windows in the grid will have the same value. |
Definition at line 269 of file image.py.