0.35.6
Class representing an image. This class allows to manipulate easily images directly in the browser or in node.
This library is designed to deal with scientific images (8 or 16 bit depth) and will be able to open and process jpeg, png and uncompressed tiff images. It is designed to work in the browser as on the server side in node.
An image is characterized by:
In an image there are pixels and points:
// JavaScript code using Node.js to get some info about the image.
// We load the library that was installed using 'npm install image-js'
const { Image } = require('image-js');
// Loading an image is asynchronous and will return a Promise.
Image.load('cat.jpg').then(function (image) {
console.log('Width', image.width);
console.log('Height', image.height);
console.log('colorModel', image.colorModel);
console.log('components', image.components);
console.log('alpha', image.alpha);
console.log('channels', image.channels);
console.log('bitDepth', image.bitDepth);
});
// Convert an image to greyscale
const { Image } = require('image-js');
Image.load('cat.jpg').then(function (image) {
var grey = image.grey();
grey.save('cat-grey.jpg');
});
// Split an RGB image in its components
const { Image } = require('image-js');
Image.load('cat.jpg').then(function (image) {
var components = image.split();
components[0].save('cat-red.jpg');
components[1].save('cat-green.jpg');
components[2].save('cat-blur.jpg');
});
// For this example you will need the picture of an ecstasy pill that is available on
// wget https://raw.githubusercontent.com/image-js/core/854e70f50d63cc73d2dde1d2020fe61ba1b5ec05/test/img/xtc.png // the goal is to isolate the picture and to get a RGB histogram of the pill.
// Practically this allows to classify pills based on the histogram similarity
// This work was published at: http://dx.doi.org/10.1016/j.forsciint.2012.10.004
const { Image } = require('image-js');
const image = await Image.load('xtc.png');
const grey = image.grey({
algorithm:'lightness'
});
// we create a mask, which is basically a binary image
// a mask has as source a grey image and we will decide how to determine
// the threshold to define what is white and what is black
var mask = grey.mask({
algorithm: 'li'
});
// it is possible to create an array of Region Of Interest (Roi) using
// the RoiManager. A RoiManager will be applied on the original image
// in order to be able to extract from the original image the regions
// the result of this console.log result can directly be pasted
// in the browser
// console.log(mask.toDataURL());
var manager = image.getRoiManager();
manager.fromMask(mask);
var rois = manager.getRoi({
positive: true,
negative: false,
minSurface: 100
});
// console.log(rois);
// we can sort teh rois by surface
// for demonstration we use an arrow function
rois.sort((a, b) => b.surface - a.surface);
// the first Roi (the biggest is expected to be the pill)
var pillMask = rois[0].getMask({
scale: 0.7 // we will scale down the mask to take just the center of the pill and avoid border effects
});
// image-js remembers the parent of the image and the relative
// position of a derived image. This is the case for a crop as
// well as for Roi
var pill = image.extract(pillMask);
pill.save('pill.jpg');
var histogram = pill.getHistograms({ maxSlots: 16 });
console.log(histogram);
// Example of use of IJS in the browser
<script>
var canvas = document.getElementById('myCanvasID');
var image = IJS.fromCanvas(canvas);
</script>
// Image from matrix of values
const [min, max] = d3.extent(temperatures)
const colorScaler = d3.scaleSequential([min, max], d3.interpolateRdYlBu);
// size = rows * columns * channels
const data = new Uint8Array(2*3*3);
for (let i = 0; i < temperatures.length; i++) {
const {r, g, b} = d3.rgb(colorScaler(temperatures[i]));
data[i*3] = r;
data[i*3 + 1] = g;
data[i*3 + 2] = b;
}
const image = new Image(2, 3, data, { kind: 'RGB' });
// or
const image = new Image({ width: 2, height: 3, data, kind: 'RGB'});
Load an image
((string | ArrayBuffer | Buffer | Uint8Array))
URL of the image (browser, can be a dataURL) or path (Node.js)
or buffer containing the binary data
(object?)
In the browser, the options object is passed to the underlying
fetch
call, along with
the data URL. For binary data, the option specify decoding options.
Name | Description |
---|---|
options.ignorePalette boolean?
|
When set to true and loading a tiff from binary data, if the tiff is of type 3 (palette), load as single channel greyscale rather than as a pseudo-colored RGB. |
Promise<Image>
:
const image = await Image.load('https://example.com/image.png');
This function is the black top hat (also called black hat). In mathematical morphology and digital image processing, top-hat transform is an operation that extracts small elements and details from given images. The black top-hat transform is defined dually as the difference between the closed and the input image. Top-hat transforms are used for various image processing tasks, such as feature extraction, background equalization, image enhancement, and others. (Wikipedia) http://docs.opencv.org/2.4/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
Image
:
Total number of channels. Is equal to image.components + image.alpha
.
Type: number
This method checks if a process can be applied on the current image
Clear the bit of a pixel using a pixel index. This method can only be called on binary images.
Clear the bit of a pixel using coordinates.
In mathematical morphology, the closing of a set A by a structuring element B is the erosion of the dilation of that set (Wikipedia). In image processing, closing is, together with opening, the basic workhorse of morphological noise removal. Opening removes small objects, while closing removes small holes. http://docs.opencv.org/2.4/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
Image
:
Change the image color depth. The color depth is the number of bits that is assigned to each point of a channel. For normal images it is 8 bits meaning the value is between 0 and 255. Currently only conversion from 1, 8 or 16 bits towards 8 or 16 bits are allowed.
(number
= 8
)
Image
:
The new image
var newImage = image.colorDepth(8);
Color model of the image.
Type: ColorModel
Number of color channels in the image. A grey image has 1 component. An RGB image has 3 components.
Type: number
(object?
= {}
)
options
Name | Description |
---|---|
options.channels Array?
|
Array of channels to treat. Defaults to all channels |
options.bitDepth number
(default this.bitDepth )
|
A new bit depth can be specified. This allows to use 32 bits to avoid clamping of floating-point numbers. |
options.normalize boolean
(default false )
|
|
options.divisor number
(default 1 )
|
|
options.border string
(default 'copy' )
|
|
options.algorithm string
(default 'auto' )
|
Either 'auto', 'direct', 'fft' or 'separable'. fft is much faster for large kernel. If the separable algorithm is used, one must provide as kernel an array of two 1D kernels. The 'auto' option will try to separate the kernel if that is possible. |
Image
:
Crops the image
(object?
= {}
)
Name | Description |
---|---|
options.x number
(default 0 )
|
x coordinate to place the zero of the new image |
options.y number
(default 0 )
|
y coordinate to place the zero of the new image |
options.width number
(default this.width-x )
|
width of the new image |
options.height number
(default this.height-y )
|
height of the new image |
Image
:
The new cropped image
var cropped = image.crop({
x:0,
y:0
});
Crops the image based on the alpha channel This removes lines and columns where the alpha channel is lower than a threshold value.
Image
:
Typed array holding the image data.
Type: TypedArray
Dilatation is one of two fundamental operations (with erosion) in morphological image processing from which all other morphological operations are based (from Wikipedia). Replaces each value with it's local maximum among the pixels with a kernel value of 1. http://docs.opencv.org/2.4/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.html https://en.wikipedia.org/wiki/Dilation_(morphology)
Image
:
Erosion is one of two fundamental operations (with dilatation) in morphological image processing from which all other morphological operations are based (from Wikipedia). Replaces each value with it's local minimum among the pixels with a kernel value of 1. http://docs.opencv.org/2.4/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.html https://en.wikipedia.org/wiki/Erosion_(morphology)
Image
:
Computes the Feret diameters https://www.sympatec.com/en/particle-measurement/glossary/particle-shape/# http://portal.s2nano.org:8282/files/TEM_protocol_NANoREG.pdf
object
:
Object with {min, max, minLine: {Array<Array
>}, maxLine: {Array<Array
>}}
Flip an image horizontally.
this
:
Flip an image vertically. The image
this
:
Get the bit of a pixel using a pixel index. This method can only be called on binary images.
number
:
0: bit is unset, 1: bit is set
Creates a new canvas element and draw the image inside it
Canvas
:
Create a grey image based on the selected channel
Image
:
A grey image with the extracted channel
Returns an array (number of channels) of array (number of slots) containing the number of data of a specific intensity. Intensity may be grouped by the maxSlots parameter.
(object?
= {}
)
Name | Description |
---|---|
options.maxSlots number?
|
Number of slots in the resulting array. The intensity will be evently distributed between 0 and the maxValue allowed for this image (255 for usual images). If maxSlots = 8, all the intensities between 0 and 31 will be placed in the slot 0, 32 to 63 in slot 1, ... |
Array<Array<number>>
:
image.getHistograms({
maxSlots: 8,
useAlpha: false
});
Returns the moment of an image (https://en.wikipedia.org/wiki/Image_moment)
number
:
An image may be derived from another image either by a crop or because it is a ROI (region of interest) Also a region of interest can be reprocessed to generated another set of region of interests. It is therefore important to keep the hierarchy of images to know which image is derived from which one and be able to get the relative position of one image in another This methods takes care of this.
(Image)
(Array<number> | boolean)
:
Retrieve the data of the current image as RGBA 8 bits The source image may be:
(Uint8Array | Uint8ClampedArray)
:
Array with the data
Create a new manager for regions of interest based on the current image.
(object?)
RoiManager
:
Returns a threshold for the creation of a binary mask with the mask()
method.
(object?
= {}
)
Name | Description |
---|---|
options.algorithm ThresholdAlgorithm
(default 'otsu' )
|
number
:
(object?
= {}
)
Name | Description |
---|---|
options.direction GradientDirection?
|
|
options.kernelX Array<Array<number>>?
|
|
options.kernelY Array<Array<number>>?
|
|
options.border string
(default 'copy' )
|
|
options.channels any?
|
|
options.bitDepth number
(default this.bitDepth )
|
Specify the bitDepth of the resulting image |
Image
:
Converts the current image to greyscale. The source image has to be RGB. If there is an alpha channel we need to decide what to do:
(object?
= {}
)
Name | Description |
---|---|
options.algorithm (GreyAlgorithm | GreyAlgorithmCallback)
(default 'luma709' )
|
Algorithm to get the grey value from RGB values |
options.keepAlpha boolean
(default false )
|
If true, the RGB values are treated separately from the alpha channel and the method returns a GREYA image. |
options.mergeAlpha boolean
(default true )
|
If true, the alpha channel will be used to scale the grey pixel. |
options.out Image?
|
Image
:
Level the image for by default have the minimal and maximal values.
(object?
= {}
)
Name | Description |
---|---|
options.algorithm string
(default 'range' )
|
|
options.channels SelectedChannels?
|
Specify which channels should be processed |
options.min number
(default this.min )
|
minimal value after levelling |
options.max number
(default this.max )
|
maximal value after levelling |
this
:
Returns an array of object with position.
(object?
= {}
)
Name | Description |
---|---|
options.mask Image?
|
Region of the image that is analyzed. The rest is omitted. |
options.region number
(default 3 )
|
1, 2 or 3. Define the region around each points that is analyzed. 1 corresponds to 4 cross points, 2 to the 8 points around and 3 to the 12 points around the central pixel. |
options.removeClosePoints number
(default 0 )
|
Remove pts which have a distance between them smaller than this param. |
options.invert boolean
(default false )
|
Search for minima instead of maxima |
options.maxEquals number
(default 2 )
|
Maximal number of values that may be equal to the maximum |
Array<number>
:
Array whose size is the number of channels
Creation of binary mask is based on the determination of a threshold You may either choose among the provided algorithm or just specify a threshold value
(object?
= {}
)
Name | Description |
---|---|
options.algorithm (ThresholdAlgorithm |
(default 'threshold' )
|
|
options.threshold number
(default 0.5 )
|
If the algorithm is 'threshold' specify here the value (0 to 1). |
options.useAlpha boolean
(default true )
|
Apply the alpha channel to determine the intensity of the pixel. |
options.invert boolean
(default false )
|
Invert the resulting image |
Image
:
Binary image containing the mask
Each pixel of the image becomes the median of the neighbor pixels.
(object
= {}
)
Name | Description |
---|---|
options.channels SelectedChannels?
|
Specify which channels should be processed. |
options.radius number
(default 1 )
|
Distance of the square to take the mean of. |
options.border string
(default 'copy' )
|
Algorithm that will be applied after to deal with borders. |
Image
:
Computes the minimum bounding box around a binary image https://www.researchgate.net/profile/Lennert_Den_Boer2/publication/303783472_A_Fast_Algorithm_for_Generating_a_Minimal_Bounding_Rectangle/links/5751a14108ae6807fafb2aa5.pdf
Array<Array<number>>
:
In mathematical morphology and digital image processing, a morphological gradient is the difference between the dilation and the erosion of a given image. It is an image where each pixel value (typically non-negative) indicates the contrast intensity in the close neighborhood of that pixel. It is useful for edge detection and segmentation applications. http://docs.opencv.org/2.4/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
Image
:
In mathematical morphology, opening is the dilation of the erosion of a set A by a structuring element B. Together with closing, the opening serves in computer vision and image processing as a basic workhorse of morphological noise removal. Opening removes small objects from the foreground (usually taken as the bright pixels) of an image, placing them in the background, while closing removes small holes in the foreground, changing small islands of background into foreground. (Wikipedia) http://docs.opencv.org/2.4/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
Image
:
Paint a label or labels on the current image.
(object?
= {}
)
Name | Description |
---|---|
options.color (Array<number> | string)
(default 'red' )
|
Array of 3 elements (R, G, B) or a valid css color. |
options.colors (Array<Array<number>> | Array<string>)?
|
Array of Array of 3 elements (R, G, B) for each color of each label. |
options.font (string | Array<string>)
(default '12px Helvetica' )
|
Paint the labels in a different CSS style |
options.rotate (number | Array<number>)
(default 0 )
|
Rotate each label of a define angle |
this
:
The original painted image
Paint a mask or masks on the current image.
(object?
= {}
)
Name | Description |
---|---|
options.color (Array<number> | string)?
|
Array of 3 elements (R, G, B) or a valid css color. |
options.colors (Array<Array<number>> | Array<string>)?
|
Array of Array of 3 elements (R, G, B) for each color of each mask |
options.randomColors boolean
(default true )
|
To paint each mask with a random color if color and colors are undefined |
options.distinctColors boolean
(default false )
|
To paint each mask with a different color if color and colors are undefined |
options.alpha number
(default 255 )
|
Value from 0 to 255 to specify the alpha. |
options.labels Array<string>?
|
Array of labels to display. Should the the same size as masks. |
options.labelsPosition Array<Array<number>>?
|
Array of points [x,y] where the labels should be displayed. By default it is the 0,0 position of the correesponding mask. |
options.labelColor string
(default 'blue' )
|
Define the color to paint the labels |
options.labelFont string
(default '12px Helvetica' )
|
Paint the labels in a different CSS style |
this
:
The original painted image
Paint pixels on the current image.
(object?
= {}
)
Name | Description |
---|---|
options.color (Array<number> | string)?
|
Array of 3 elements (R, G, B) or a valid css color. |
options.colors (Array<Array<number>> | Array<string>)?
|
Array of Array of 3 elements (R, G, B) for each color of each mask |
options.randomColors boolean
(default true )
|
To paint each mask with a random color if color and colors are undefined |
options.distinctColors boolean
(default false )
|
To paint each mask with a different color if color and colors are undefined |
options.shape object?
|
Definition of the shape, see Shape contructor. |
this
:
The original painted image
Paint a polygon defined by an array of points.
this
:
The original painted image
Paint an array of polygons on the current image.
(object?
= {}
)
Name | Description |
---|---|
options.color (Array<number> | string)?
|
Array of 3 elements (R, G, B) or a valid css color. |
options.colors (Array<Array<number>> | Array<string>)?
|
Array of Array of 3 elements (R, G, B) for each color of each mask |
options.randomColors boolean
(default true )
|
To paint each mask with a random color if color and colors are undefined |
options.distinctColors boolean
(default false )
|
To paint each mask with a different color if color and colors are undefined |
options.shape object?
|
Definition of the shape, see Shape contructor. |
this
:
The original painted image
Paint a polyline defined by an array of points.
this
:
The original painted image
Paint polylines on the current image.
(object?
= {}
)
Name | Description |
---|---|
options.color (Array<number> | string)?
|
Array of 3 elements (R, G, B) or a valid css color. |
options.colors (Array<Array<number>> | Array<string>)?
|
Array of Array of 3 elements (R, G, B) for each color of each mask |
options.randomColors boolean
(default true )
|
To paint each mask with a random color if color and colors are undefined |
options.distinctColors boolean
(default false )
|
To paint each mask with a different color if color and colors are undefined |
options.shape object?
|
Definition of the shape, see Shape contructor. |
this
:
The original painted image
Resize an image
(object?
= {}
)
Name | Description |
---|---|
options.width number
(default this.width )
|
new width |
options.height number
(default this.height )
|
new height |
options.factor number
(default 1 )
|
scaling factor (applied to the new width and height values) |
options.interpolation InterpolationAlgorithm
(default 'nearestNeighbor' )
|
|
options.preserveAspectRatio boolean
(default true )
|
preserve width/height ratio if only one of them is defined |
Image
:
Make a copy of the current image and convert to RGBA 8 bits Those images are the one that are displayed in a canvas. RGB model in 8 bits per channel and containing as well an alpha channel. The source image may be:
Image
:
New image in RGB color model with alpha channel
var rgbaImage = image.rgba8();
Rotates an image.
(number)
Angle of the rotation in degrees
(object?)
Name | Description |
---|---|
options.interpolation InterpolationAlgorithm
(default 'nearestNeighbor' )
|
Interpolation algorithm to use if
angle
is not a multiple of 90
|
Image
:
The new rotated image
Save the image to disk (Node.js only)
(string)
(object?
= {}
)
Name | Description |
---|---|
options.format string?
|
One of: png, jpg, bmp (limited support for bmp). If not specified will try to infer from filename |
options.useCanvas boolean
(default false )
|
Force use of the canvas API to save the image instead of a JavaScript implementation |
options.encoder object?
|
Specify options for the encoder if applicable. |
Promise
:
Resolves when the file is fully written
Applies the Scharr operator.
(object?)
Name | Description |
---|---|
options.direction GradientDirection?
|
|
options.border string
(default 'copy' )
|
|
options.channels any?
|
|
options.bitDepth number
(default this.bitDepth )
|
Specify the bitDepth of the resulting image |
Image
:
Set the bit of a pixel using a pixel index. This method can only be called on binary images.
Set the bit of a pixel using coordinates. This method can only be called on binary images.
We set the data of the image from a matrix. The size of the matrix and the data have to be the same.
this
:
Applies the Sobel operator.
(object?)
Name | Description |
---|---|
options.direction GradientDirection?
|
|
options.border string
(default 'copy' )
|
|
options.channels any?
|
|
options.bitDepth number
(default this.bitDepth )
|
Specify the bitDepth of the resulting image |
Image
:
Creates a blob from the image and return a Promise. This function is only available in the browser.
(string
= 'image/png'
)
A String indicating the image format. The default type is image/png.
(string
= 0.8
)
A Number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp. If this argument is anything else, the default value for image quality is used. Other arguments are ignored.
Promise
:
Encodes the image and returns a buffer
Uint8Array
:
Toggle (invert) the bit of a pixel using a pixel index. This method can only be called on binary images.
Toggle (invert) the bit of a pixel using coordinates.
This function is the white top hat (also called top hat). In mathematical morphology and digital image processing, top-hat transform is an operation that extracts small elements and details from given images. The white top-hat transform is defined as the difference between the input image and its opening by some structuring element. Top-hat transforms are used for various image processing tasks, such as feature extraction, background equalization, image enhancement, and others. (Wikipedia) http://docs.opencv.org/2.4/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
Image
:
Transform a quadrilateral into a rectangle
Image
:
The new image, which is a rectangle
var cropped = image.warpingFourPoints({
pts: [[0,0], [100, 0], [80, 50], [10, 50]]
});
Class representing stack of images
We will try to move a set of images in order to get only the best common part of them. In a stack, we compare 2 consecutive images or directly to a parent. Ignoring border may be dangerous ! If there is a shape on the side of the image there will be a continuous shift if you ignore border. By default it is better to leave it to 0,0 Now if the background is not black there will also be no way to shift ... It may therefore be much better to make a background correction before trying to match and crop.
Stack
:
Class to manage Region Of Interests
Calculates the number of pixels that are involved in border Border are all the pixels that touch another "zone". It could be external or internal. If there is a hole in the zone it will be counted as a border. All the pixels that touch the box are part of the border and are calculated in the getBoxPixels procedure
Retrieve all the IDs (array of number) of the regions that are in contact with this specific region. It may be external or internal
Retrieve all the length (array of number) of the contacts with this specific region. It may be external or internal
Number of pixels of the Roi that touch the rectangle This is useful for the calculation of the border because we will ignore those special pixels of the rectangle border that don't have neighbours all around them.
Retrieve all the IDs or the Roi touching the box surrouding the region
It should really be an array to solve complex cases related to border effect
Like the image
The first row of 1 will be surrouned by 2 differents zones
Or even worse
The cross will be surrouned by 4 differents zones
However in most of the cases it will be an array of one element
Returns a binary image (mask) containing only the border of the mask
Diameter of a circle of equal projection area
Calculates the number of pixels that are in the external border of the Roi Contour are all the pixels that touch an external "zone". All the pixels that touch the box are part of the border and are calculated in the getBoxPixels procedure
Returns a binary image (mask) for the corresponding ROI
Image
:
Returns a mask (1 bit Image)
Calculates information about holes
Returns a binary image containing the mask
Calculates the maximum length between two pixels of the Roi.
Diameter of a circle of equal perimeter
Return the perimeter of the ROI
Get the category in which each external pixel belongs
Color model of an image
Type:
("GREY"
| "RGB"
| "HSL"
| "HSV"
| "CMYK"
)
A manager of Regions of Interest. A RoiManager is related to a specific Image and may contain multiple layers. Each layer is characterized by a label whose is name by default 'default'
RoiMap
:
This method allows to create a ROIMap using the water shed algorithm. By default this algorithm will fill the holes and therefore the lowest value of the image (black zones). If no points are given, the function will look for all the minimal points. If no mask is given the algorithm will completely fill the image. Please take care about the value that has be in the mask ! In order to be coherent with the expected mask, meaning that if it is a dark zone, the mask will be dark the normal behaviour to fill a zone is that the mask pixel is clear (value of 0) ! However if you work in the 'invert' mode, the mask value has to be 'set' and the method will look for maxima.
(object
= {}
)
Name | Description |
---|---|
options.points Array<Array<number>>?
|
Array of points [[x1,y1], [x2,y2], ...]. |
options.fillMaxValue number?
|
Limit of filling. By example, we can fill to a maximum value 32000 of a 16 bitDepth image. If invert this will corresponds to the minimal value |
options.image Image
(default this )
|
By default the waterShed will be applied on the current image. However waterShed can only be applied on 1 component image. This allows to specify a grey scale image on which to apply waterShed.. |
options.mask Image?
|
A binary image, the same size as the image. The algorithm will fill only if the current pixel in the binary mask is true. |
options.invert boolean
(default false )
|
By default we fill the minima |
RoiMap
:
Returns an array of masks See Roi.getAnalysisMasks for the options
(object?
= {}
)
Array<Image>
:
Retuns an array of masks (1 bit Image)
Returns an array of masks See Roi.getMask for the options
(object?
= {}
)
Array<Image>
:
Retuns an array of masks (1 bit Image)
Allows to select ROI based on size, label and sign.
(object
= {}
)
Name | Description |
---|---|
options.label string
(default 'default' )
|
Label of the layer containing the ROI |
options.positive boolean
(default true )
|
Select the positive region of interest |
options.negative boolean
(default true )
|
Select he negative region of interest |
options.minSurface number
(default 0 )
|
|
options.maxSurface number
(default Number.POSITIVE_INFINITY )
|
|
options.minWidth number
(default 0 )
|
|
options.minHeight number
(default Number.POSITIVE_INFINITY )
|
|
options.maxWidth number
(default 0 )
|
|
options.maxHeight number
(default Number.POSITIVE_INFINITY )
|
|
options.minRatio number
(default 0 )
|
Ratio width / height |
options.maxRatio number
(default Number.POSITIVE_INFINITY )
|
Array<Roi>
:
In place modification of the roiMap that joins regions of interest
(object?
= {}
)
Name | Description |
---|---|
options.algorithm (string | function (object, number, number))
(default 'commonBorderLength' )
|
algorithm used to decide which ROIs are merged. Current implemented algorithms are 'commonBorderLength' that use the parameters 'minCommonBorderLength' and 'maxCommonBorderLength' as well as 'commonBorderRatio' that uses the parameters 'minCommonBorderRatio' and 'maxCommonBorderRatio'. |
options.minCommonBorderLength number
(default 5 )
|
minimal common number of pixels for merging |
options.maxCommonBorderLength number
(default 100 )
|
maximal common number of pixels for merging |
options.minCommonBorderRatio number
(default 0.3 )
|
minimal common border ratio for merging |
options.maxCommonBorderRatio number
(default 1 )
|
maximal common border ratio for merging |
this
:
Paint the ROI on a copy of the image and return this image. For painting options Image.paintMasks For ROI selection options, see RoiManager.getMasks
(object?
= {}
)
all the options to select ROIs
Name | Description |
---|---|
options.labelProperty string?
|
Paint a mask property on the image. May be any property of the ROI like for example id, surface, width, height, meanX, meanY. |
options.pixelSize number?
|
Size of a pixel in SI |
options.unit string
(default "pixel" )
|
Unit in which to display the values |
Image
:
The painted RGBA 8 bits image
Class representing a shape
(object?)
Name | Description |
---|---|
options.kind string
(default 'cross' )
|
Predefined matrix shape, 'cross' or 'smallCross' |
options.shape string?
|
Value may be 'square', 'rectangle', 'circle', 'ellipse' or 'triangle' The size of the shape will be determined by the size, width and height. A Shape is by default filled. |
options.size number?
|
|
options.width number
(default options.size )
|
width of the shape. Must be odd. |
options.height number
(default options.size )
|
width of the shape. Must be odd. |
options.filled boolean
(default true )
|
If false only the border ot the shape is taken into account. |
Direction of a gradient filter
Type:
("x"
| "y"
| "xy"
)
Type:
("luma709"
| "luma601"
| "maximum"
| "minimum"
| "average"
| "minmax"
| "red"
| "green"
| "blue"
| "cyan"
| "magenta"
| "yellow"
| "black"
| "hue"
| "saturation"
| "lightness"
)
Call back that converts the RGB channels to grey. It will be clamped after.
Type: Function
(number)
value of the red channel
(number)
value of the green channel
(number)
value of the blue channel
number
:
value of the grey channel
Type:
("nearestNeighbor"
| "bilinear"
)
Returns the perimeter represented by the points (a polygon)
Specify which channels should be processed
Type: (undefined | number | string | Array<number> | Array<string>)
Returns the surface represented by the points (a polygon)
Type:
("huang"
| "intermodes"
| "isodata"
| "li"
| "maxentropy"
| "mean"
| "minerror"
| "minimum"
| "moments"
| "otsu"
| "percentile"
| "renyientropy"
| "shanbhag"
| "triangle"
| "yen"
)