Computer vision
ABS
abs(Array of F64 a
) -> Array -r
STABLE
The absolute of an image.
Takes the absolute value of each element in a floating point graylevel image.
Parameter | Description |
---|---|
a | Image to take the absolute of. |
Return: Absolute image.
CV:CONST:COLORMAP_HOT
cv:const:colormap_hot( ) -> Charstring
STABLE
Stored function with colormap ID.
Return: Colormap ID as string.
CV:CONST:COLORMAP_JET
cv:const:colormap_jet( ) -> Charstring
STABLE
Stored function with colormap ID.
Return: Colormap ID as string.
CV:CONST:COLORMAP_VIRIDIS
cv:const:colormap_viridis( ) -> Charstring
STABLE
Stored function with colormap ID.
Return: Colormap ID as string.
CV:CONST:THRESH_BINARY
cv:const:thresh_binary( ) -> Charstring
STABLE
Stored function with thresholding type ID.
CV:CONST:THRESH_BINARY_INV
cv:const:thresh_binary_inv( ) -> Charstring
STABLE
Stored function with thresholding type ID.
CV:CONST:THRESH_TO_ZERO
cv:const:thresh_to_zero( ) -> Charstring
STABLE
Stored function with thresholding type ID.
CV:CONST:THRESH_TO_ZERO_INV
cv:const:thresh_to_zero_inv( ) -> Charstring
STABLE
Stored function with thresholding type ID.
CV:CONST:THRESH_TRUNK
cv:const:thresh_trunk( ) -> Charstring
STABLE
Stored function with thresholding type ID.
CV:CROP
cv:crop(Array of U8 im
, Integer y
, Integer x
, Integer h
, Integer w
) -> Array out
STABLE
Cut out a w*h subimage at position (x,y) (1-indexed).
Parameter | Description |
---|---|
im | The image to be cropped (size [height,width[,channels]]) |
y | The y coordinate of the crop rectangle (the top edge, 1-indexed) |
x | The x coordinate of the crop rectangle (the left edge, 1-indexed) |
h | The height of the crop rectangle |
w | The width of the crop rectangle |
Return: A "U8" array of size [h,w[,channels]]
CV:DRAW_RECT
cv:draw_rect(Array im
, Integer y0
, Integer y1
, Integer x0
, Integer x1
, Array of U8 col
) -> Array out
STABLE
Draw a rectangle in a color image.
Draws a rectangle at (y0,x0) -> (y1,x1) with color col
.
Parameter | Description |
---|---|
im | The image where the rectangle is drawn. |
y0 | Top of rectangle. |
y1 | Bottom of rectangle. |
x0 | Left side of rectangle. |
x1 | Right side of rectangle. |
col | Rectangle color (RGB). |
Return: Image with rectangle drawn.
CV:FILTER_2D
cv:filter_2d(Array of U8 im
, Array of F64 filter
) -> Array out
STABLE
Filter graylevel image with a kernel.
This filters the graylevel image im
with a kernel using convolution.
The function uses padding, so the output image will have the same
size as the input image.
Parameter | Description |
---|---|
im | The graylevel image to filter. |
filter | The filter kernel. |
Return: Graylevel image of same size and type as original image.
cv:filter_2d(Array of F64 im
, Array of F64 filter
) -> Array -r
STABLE
Filter graylevel (floating point) image with a kernel.
This filters the graylevel image im
with a kernel using convolution.
The function uses padding, so the output image will have the same
size as the input image.
Parameter | Description |
---|---|
im | The graylevel image to filter. |
filter | The filter kernel. |
Return: Graylevel image of same size and type as original image.
CV:FILTER_2D_NO_PAD
cv:filter_2d_no_pad(Array of F64 im
, Array of F64 filter
) -> Array -r
STABLE
Filter graylevel (floating point) image with a kernel, without padding.
This filters the graylevel image im
with a kernel using convolution.
The function does not use padding, so the output image will be smaller
than the input image.
Parameter | Description |
---|---|
im | The graylevel image to filter. |
filter | The filter kernel. |
Return: Graylevel image of same type as original image.
CV:FINDMAX
cv:findmax(Array of F64 a)->(Integer
, Integer
)
STABLE
Find index for maximum value in 2D array.
Parameter | Description |
---|---|
a[sh,sw] | The 2D array to search for maximum. |
Return: A tuple (x,y) with the coordinate of the maximum.
cv:findmax(Array of F32 a)->(Integer
, Integer
)
STABLE
Find index for maximum value in 2D array.
Parameter | Description |
---|---|
a[sh,sw] | The 2D array to search for maximum. |
Return: A tuple (x,y) with the coordinate of the maximum.
CV:GET_GAUSSIAN_KERNEL
cv:get_gaussian_kernel(Integer sz
, Real sigma
) -> Array
STABLE
A gaussian kernel of size sz
and standard deviation sigma
.
Parameter | Description |
---|---|
sz | Size of gaussian kernel. |
sigma | Standard deviation of gaussian kernel. |
Return: Gaussian kernel as floating point (sz x sz) image.
CV:GRAY2RGB
cv:gray2rgb(Array of U8 im
, Charstring colormap
) -> Array of U8 rgb
STABLE
Convert graylevel image to RGB using colormap
cv:gray2rgb(Array of U8 im
) -> Array -r
STABLE
Convert graylevel image to RBG.
Converts a graylevel image (MxN) to an RGB image (MxNx3). All color channels of the RGB image will have the same value as the respective pixels in the graylevel image.
Parameter | Description |
---|---|
im | The graylevel image to convert. |
Return: An RGB image (MxNx3).
cv:gray2rgb(Array of U8 im
, Charstring colormap
, Boolean normalize
) -> Array out
STABLE
Convert graylevel image to RGB using colormap, with option to normalize RGB image.
Converts a graylevel image (MxN) to an RGB image (MxNx3). The translation
of the colors to the RGB image will be determined by the colormap. When normalize
is true, the graylevel image will be normailzed to use the full range of unsigned
byte values (0-255) before converting to RGB.
Parameter | Description |
---|---|
im | The graylevel image to convert. |
colormap | The colormap for translating the graylevel values to RGB. |
Return: An RGB image (MxNx3).
CV:HIST
cv:hist(Array of U8 im
) -> Array
STABLE
Histogram of image.
Computes a histogram with 256 bins for an U8 image.
Parameter | Description |
---|---|
im | Image to compute histogram. |
Return: 1D array of histogram values.
CV:MASK
cv:mask(Array of U8 im
, Array of U8 mask
) -> Array out
STABLE
Apply a mask to an image (graylevel or RGB).
A pixel under the mask will keep its value. All pixels outside the mask will be set to zero.
Parameter | Description |
---|---|
im | The image to be masked (size [h,w[,3]]) |
mask | The mask to apply (size [h,w]) |
Return: A "U8" image of size [h,w[,3]]
CV:MATCH_TEMPLATE
cv:match_template(Array of F32 image
, Array of F32 template
) -> Array -r
STABLE
Template matching for graylevel images.
Implements template matching using template matching mode similar to OpenCV TM_CCORR_NORMED.
Parameter | Description |
---|---|
image | Image to search for template. |
template | Template to find in image. |
Return: A template map (same size as input image) with TM_CCORR_NORMED values (high values means good match with template at that position).
CV:OTSU_BINARIZATION
cv:otsu_binarization(Array of U8 im
) -> Integer threshold
STABLE
Otsu binarization.
Computes the Otsu's binarization threshold for an image. (See https://en.wikipedia.org/wiki/Otsu%27s_method)
Parameter | Description |
---|---|
im | Graylevel image for which to find the Otsu |
binarization threshold value. |
Return: The Otsu binarization threshold value.
CV:RESIZE
cv:resize(Array of U8 im
, Integer h
, Integer w
) -> Array out
STABLE
Resize image (RGB or graylevel image) using nearest neighbor sampling.
Parameter | Description |
---|---|
im | The image to resize (can be RGB or graylevel) |
h | New image height |
w | New image width |
Return: A "U8" image with size [h,w[,3]]
CV:RGB2GRAY
cv:rgb2gray(Array of U8 mat
) -> Array -r
STABLE
Convert RGB image to graylevel.
Converts an RGB image (MxNx3) to a graylevel image (MxN).
Parameter | Description |
---|---|
mat | The RGB image to convert. |
Return: A graylevel image of size MxN.
CV:SCALE
cv:scale(Array of U8 image
, Real scale
) -> Array
STABLE
Resize image by a factor of image size.
Parameter | Description |
---|---|
image | The image to scale |
scale | The scale factor |
Return: A scaled version of the input image
CV:SLICE
cv:slice(Array of U8 a
, Integer s
, Integer e
) -> Array -r
STABLE
Slice array.
Extracts subarray from index s
to index e
.
Parameter | Description |
---|---|
a | Array to slice. |
s | Start index of slice (inclusive). |
e | End index of slice (inclusive). |
Return: Array slice.
CV:SLICE2
cv:slice2(Array of U8 a
, Array of I64 iy
, Array of I64 ix
) -> Array -r
STABLE
Slice 2D array.
Extracts 2D subarray with row indices in iy
and column indices in ix
.
Parameter | Description |
---|---|
a | 2D array to slice. |
iy | Array with row indices to extract. |
ix | Array with column indices to extract. |
Return: 2D array slice.
CV:SLICE3
cv:slice3(Array of U8 a
, Array of I64 iy
, Array of I64 ix
, Array of I64 ic
) -> Array -r
STABLE
Slice 3D array.
Extracts 3D subarray with row indices in iy
, column indices in ix
, and
"color" indices in ic
.
Parameter | Description |
---|---|
a | 3D array (color image) to slice. |
iy | Array with row indices to extract. |
ix | Array with column indices to extract. |
ic | Array with "color" indices to extract. |
Return: 3D array slice.
CV:SSIM
cv:ssim(Charstring img1_path
, Charstring img2_path
, Real filter_size
, Real filter_sigma
, Real k1
, Real k2
) -> Real
STABLE
Structural similarity index measure (SSIM) of two images files.
Measures similarity between two graylevel images on file. (See https://en.wikipedia.org/wiki/Structural_similarity)
Parameter | Description |
---|---|
img1_path | Path to first image. |
img2_path | Path to second image. |
filter_size | Size of gaussian filter used in SSIM. |
filter_sigma | Standard deviation of gaussian filter used in SSIM. |
k1 | Constant for stabilizing division (usually 0.01). |
k2 | Constant for stabilizing division (usually 0.03). |
Return: A value in the range [1,-1], where 1 indicates perfect similarity, 0 indicates no similarity, and -1 indicates perfect anti-correlation.
cv:ssim(Array of F64 img1
, Array of F64 img2
, Real filter_size
, Real filter_sigma
, Real k1
, Real k2
) -> Real
STABLE
Structural similarity index measure (SSIM) of two images.
Measures similarity between two (floating point) graylevel images. (See https://en.wikipedia.org/wiki/Structural_similarity)
Parameter | Description |
---|---|
img1 | First image. |
img2 | Second image. |
filter_size | Size of gaussian filter used in SSIM. |
filter_sigma | Standard deviation of gaussian filter used in SSIM. |
k1 | Constant for stabilizing division (usually 0.01). |
k2 | Constant for stabilizing division (usually 0.03). |
Return: A value in the range [1,-1], where 1 indicates perfect similarity, 0 indicates no similarity, and -1 indicates perfect anti-correlation.
CV:THRESHOLD
cv:threshold(Array of U8 im
, Integer thresh
, Integer maxval
, Charstring thresh_type
) -> Array out
STABLE
Graylevel thresholding.
Applies fixed-level thresholding to a grayscale image.
There are several types of thresholding supported by the function
(determined by the thresh_type
parameter).
Parameter | Description |
---|---|
im | Image to threshold. |
thresh | Threshold value (0-255). |
maxval | Max value to use with THRESH_BINARY and |
THRESH_BINARY_INV thresholding. | |
thresh_type | Thresholding type ID. |
Return: Thresholded image.
DOT
dot(Array of F32 source
, Array of F32 template
, Integer row
, Integer col
) -> Real
STABLE
Dot product of color image and color template.
Takes the dot product of the template and the
region of the image that is covered by the template.
Note that the template needs to fit in the image so the
distance from the (row,col)
position to the image bottom right corner cannot be
smaller than the size of the template.
Parameter | Description |
---|---|
source | Color image to use in dot product. |
template | Color template to use in dot product. |
row | Y-coordinate for top left position of template. |
col | X-coordinate for top left position of template. |
Return: Dot product between image and template at position (row,col)
in the image.
DOT2
dot2(Array of F32 source
, Array of F32 template
, Integer row
, Integer col
) -> Real
STABLE
Dot product of graylevel image and graylevel template.
Takes the dot product of the template and the
region of the image that is covered by the template.
Note that the template needs to fit in the image so the
distance from the (row,col)
position to the image bottom right corner cannot be
smaller than the size of the template.
Example:
src = | 1 2 3 4 | temp = | 1 2 | (row,col) = (1,3)
| 5 6 7 8 | | 3 4 |
| 4 3 2 1 |
=> | 3 4 | * | 1 2 | = 1*3 + 2*4 + 7*3 + 8*4 = 64
| 7 8 | | 3 4 |
Parameter | Description |
---|---|
source | Graylevel image to use in dot product. |
template | Graylevel template to use in dot product. |
row | Y-coordinate for top left position of template. |
col | X-coordinate for top left position of template. |
Return: Dot product between image and template at position (row,col)
in the image.
PLUS
plus(Array of F64 a
, Real x
) -> Array r
STABLE
Add x
to all elements in a
.
PY:ANNOTATE
py:annotate(Array im
, Charstring label
, Vector rect
) -> Array
STABLE
Annotate an image.
Annotates an image with a text string using the Python Pillow lbrary.
Parameter | Description |
---|---|
im | The image to annotate. |
label | The text to use as annotation. |
rect | A vector [x0, y0, x1, y1] with coordinates for the |
label rectangle. |
Return: The annotated image.
PY:DISPLAY_IMAGE
py:display_image(Array im
) -> Array
STABLE
Display image in a separate window.
Displays an image in a seprate window using the Python Pillow lbrary.
Parameter | Description |
---|---|
im | The image to display. |
Return: The displayed image.
PY:IMREAD
py:imread(Charstring file
) -> Array
STABLE
Read image from file.
Reads an image from file by using the Python Pillow library.
Parameter | Description |
---|---|
file | The image filename. |
Return: Array containing the image.
PY:IMWRITE
py:imwrite(Charstring file
, Array im
) -> Array
STABLE
Write image to file.
Writes an image to file by using the Python Pillow library.
Parameter | Description |
---|---|
file | The name of the file to write. |
im | The image to write. |
Return: Array containing the image.
PY:PUT_TEXT
py:put_text(Array of U8 im
, Charstring text
, Integer y
, Integer x
) -> Array
STABLE
Write text in image (using Python Pillow).
Writes text at a chosen position in a color image by calling the Python Pillow library.
Parameter | Description |
---|---|
im | The color image to which the text will be written. |
text | The text to write. |
y | The y-coordinate of the text. |
x | The x-coordinate of the text. |
Return: The image with the text.
ROUND_TO
round_to(Array of F64 a
, Integer n
) -> Array -r
STABLE
Round image vaules.
Round each value in a floating point graylevel image to n
decimals.
Parameter | Description |
---|---|
a | Image to round. |
n | Number of decimals in output image. |
Return: Rounded image (same size and type as input image).
SUM
sum(Array of F32 a
, Integer row
, Integer col
, Integer height
, Integer width
) -> Real
STABLE
No description.
SUM2
sum2(Array of F32 a
, Integer row
, Integer col
, Integer height
, Integer width
) -> Real
STABLE
Sum region in graylevel image.
Sum of array elements in rectangular region described by (row,col,height,width). Example:
a = | 1 2 3 4 | (row,col) = (1,3) (height,width) = (2,2)
| 5 6 7 8 |
| 4 3 2 1 |
=> 3 + 4 + 7 + 8 = 22
Parameter | Description |
---|---|
a | Graylevel image. |
row | Top coordinate of rectangular region to sum. |
col | Left coordinate of rectangular region to sum. |
height | Height of rectangular region to sum. |
width | Width of rectangular region to sum. |