To use these functions, the ImageJCV Feature is required.
ReinterpretCVImageJCV i, Number newWidth, Number newhHeight newDepth, Number newNumChannels, Number Reinterprets Converts the content of an image (argument 0) as another image with different width, height, depth, number of channels or pixel format. Any parameter which is set to 1 will be replaced by the corresponding value of the original image. Buffer sizes of original and reinterpreted image must match!
Example: Convert a 16-bit grayscale image to a 32-bit RGBA image with half of the width:
input image to another pixel format.
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['reinterpretconvertCV(image, getWidth(image)/2, -1, 8, 4, 28)', 'imageconverted']]}, input) |
Parameter explanation:
- image: Original image
- getWidth(image)/2: Half width
- -1: Original height
- 8: 8 bit per pixel channel
- 4: 4 channels per pixel
- 28: 32 Bit RGBA pixel format (see JavaCV doc: AV_PIX_FMT_RGBA)
Inv(Image i)
getWidthCV(ImageCV i)
Returns the width of the given image
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['getWidth(image)', 'width']]}, input) |
getHeightCV(ImageCV i)
Returns the height of the given image
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['getHeight(image)', 'height']]}, input) |
getDepthCV(ImageCV i)
Returns the depth Inverts the pixel values of the given image
Code Block |
---|
language | js |
---|
theme | sqlEclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['getDepthSELECT inv(image) FROM Stream
|
Get(Image i, Number x, Number y)
Return the value of the pixel at the given location
Code Block |
---|
|
SELECT get(image, 100, 100) FROM Stream
|
Set(Image i, Number x, Number y, Number c)
Set the pixel at the given location to the given value
getNumChannelsCV(ImageCV i)
Returns the number of channels of the given image
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['getNumChannels(image)', 'numChannels']]}, input) |
Returns the pixel format of the given image
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['getPixelFormat(image)', 'pixelFormat']]}, input) |
resizeCV(ImageCV i, Number width, Number height)
Resizes the image to the given width and height
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['resizeCV |
Code Block |
---|
|
SELECT set(image, 100, 100)', 0.5) FROM Stream
|
Rotate(Image i, Number angle)
stretchContrastCV(ImageJCV i, Number oldMin, Number oldMax, Number newMin, Number newMax)
Converts an 16-bit 1-channel image (f.ex. a temperature map) to an 24-bit RGB grayscale image. The contrast of the new image is calculated with this formula for each pixel:
newValue = (oldValue - oldMin) / (oldMax - oldMin) * (newMax - newMin) + newMin
The example converts a temperature map to a grayscale image such that input 1000 maps to black and input 5000 maps to whiteRotates the image at the given angle in degree.
Code Block |
---|
language | js |
---|
theme | sqlEclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['stretchContrastCVSELECT rotate(image, 90.0) FROM Stream
|
Resize(Image i, 1000, 5000, 0, 255)', 'grayscale']]}, input) |
toImageCV(Number width, Number height)
Resize the image to Creates a new 32-bpp RGBA image with the given width and height
Code Block |
---|
language | js |
---|
theme | Eclipsesql |
---|
title | Example |
---|
|
SELECT resize(image, 500, 500) FROM Stream
|
Sub(Image i, Number x, Number y, Number width, Number height)
|
output = MAP({expressions=[['toImageCV(512, 512)', 'image']]}, input) |
Creates a new image with the given width, height, depth, channel count and pixel formatReturns a sub image at the given location and the given width and height.
Code Block |
---|
language | js |
---|
theme | Eclipsesql |
---|
title | Example |
---|
|
SELECT sub(image, 5, 5, 200, 200) FROM Stream
|
ToImage(<Number width, Number height>|<Matrix matrix>)
Creates a new image with the given width and height
Code Block |
---|
|
SELECT toImage(500, 500) FROM Stream
|
ToMatrix(Image i)
Return the pixel values of the given image as a matrix
|
output = MAP({expressions=[['toImageCV(512, 512, 8, 4, 28)', 'image']]}, input) /// 32bpp RGBA image |
toImageCV(Image i)
Copies the contents of the input image (from the Image feature) into a new ImageJCV image.
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['toImageCV(inputImage)', 'image']]}, input) |
Reinterprets the content of an image (argument 0) as another image with different width, height, depth, number of channels or pixel format. Any parameter which is set to 1 will be replaced by the corresponding value of the original image. Buffer sizes of original and reinterpreted image must match!
Example: Convert a 16-bit grayscale image to a 32-bit RGBA image with half of the width:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Example |
---|
linenumbers | true |
---|
|
output = MAP({expressions=[['reinterpret(image, getWidth(image)/2, -1, 8, 4, 28)', 'image']]}, input) |
Parameter explanation:
- image: Original image
- getWidth(image)/2: Half width
- -1: Original height
- 8: 8 bit per pixel channel
- 4: 4 channels per pixel
- 28: 32 Bit RGBA pixel format