This module import functions to manipulate images
Compute the bounding box of a mask
Parameters: |
|
---|---|
Returns: | a slice (ind_min,ind_max) for each dimension of the mask or None if the mask do not contain any True value. Where ind_min correspond to the first slice that contains a True value and ind_max correspond to the first slice that contains only False after slices that contain at least one True value |
Returns Type: | list of (int,int) |
Apply a mask on a given image
If background_color is None, the mask is applied as the alpha channel in image. Pixels whose value is True will have an alpha value of 255 and others will have an alpha value of 0
Else, pixels whose value is True will conserve their original color and others will have a color equal to background color
Parameters: |
|
---|---|
Returns Type: | (NxM(xP)x3(4) array of uint8) |
Concatenate all images into a single image
Use alpha to blend images one on top of each other
Warning
all images must have the same nD shape and an alpha channel (except maybe for the first one)
If alpha is True, the resulting image will use the max of all alpha channels as an alpha channel.
Warning
if the first image is a |SpatialImage|, the resulting image will also be a |SpatialImage| but no test is made to ensure consistency in the resolution of the layers
Parameters: |
|
---|---|
Returns Type: | NxM(xP)x3(4) array of uint8 |
Saturate colors in the image
Parameters: |
|
---|---|
Returns Type: | NxM(xP)x3(4) array of uint8 |
Create a mask where all pixel whose intensity is smaller than threshold are transparent.
Parameters: |
|
---|---|
Returns Type: | NxM(xP) array of bool |
Create a mask to conserve only colors around the given color.
http://en.wikipedia.org/wiki/Color_difference
Parameters: |
|
---|---|
Returns Type: | NxM(xP) array of bool |
A border is a outside black space that can be added to an array object.
Parameters: |
---|
Returns Type: | (N+x_min+x_max) x (M+y_min+y_max) x (P+z_min+z_max) array |
---|
A end margin is a inside black space that can be added into the end of array object.
Parameters: |
---|
By default, add in all directions (see also stroke).
Returns Type: | img |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from openalea.image import end_margin
img = random.random((3,4,5))
out = end_margin(img,1,0)
assert out.shape == (3,4,5)
assert (out[2,:,:] == zeros((4,5))).all()
assert (out[1:2,:,:] == img[1:2,:,:] ).all()
out = end_margin(img,1,1)
assert out.shape == (3,4,5)
assert (out[:,3,:] == zeros((3,5))).all()
assert (out[:,1:3,:] == img[:,1:3,:] ).all()
|
A stroke is an outline that can be added to an array object.
Parameters: |
---|
By default, the position of the stroke is inside (outside = False)
:Return Type : img