Image
A container for image data.
Examples:
pipeline example {
val image = Image.fromFile("example.png");
}
Stub code in Image.sdsstub
| @Experimental
class Image {
/**
* Get the width of the image in pixels.
*/
attr width: Int
/**
* Get the height of the image in pixels.
*/
attr height: Int
/**
* Get the number of channels of the image.
*/
attr channel: Int
/**
* Get the `ImageSize` of the image.
*/
attr size: ImageSize
/**
* Create an image from a file.
*
* @param path The path to the image file.
*
* @result image The image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* }
*/
@Impure([ImpurityReason.FileReadFromParameterizedPath("path")])
@PythonName("from_file")
@Category(DataScienceCategory.DataImport)
static fun fromFile(
path: String
) -> image: Image
/**
* Save the image as a JPEG file.
*
* @param path The path to the JPEG file.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* image.toJpegFile("output.jpeg");
* }
*/
@Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_jpeg_file")
@Category(DataScienceCategory.DataExport)
fun toJpegFile(
path: String
)
/**
* Save the image as a PNG file.
*
* @param path The path to the PNG file.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* image.toPngFile("output.png");
* }
*/
@Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_png_file")
@Category(DataScienceCategory.DataExport)
fun toPngFile(
path: String
)
/**
* Return a new `Image` that has the given number of channels.
*
* The original image is not modified.
*
* @param channel The new number of channels. 1 will result in a grayscale image.
*
* @result newImage The image with the given number of channels.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.changeChannel(channel = 1);
* }
*/
@Pure
@PythonName("change_channel")
@Category(DataScienceCategory.DataProcessingQImage)
fun changeChannel(
channel: Int
) -> newImage: Image
/**
* Return a new `Image` that has been resized to a given size.
*
* The original image is not modified.
*
* @param newWidth The new width of the image.
* @param newHeight The new height of the image.
*
* @result newImage The image with the given width and height.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.resize(newWidth = 100, newHeight = 50);
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun resize(
@PythonName("new_width") const newWidth: Int,
@PythonName("new_height") const newHeight: Int
) -> newImage: Image where {
newWidth >= 0,
newHeight >= 0
}
/**
* Return a new `Image` that is converted to grayscale.
*
* The new image will have the same amount of channels as the original image. If you want to change the amount of
* channels used, please use the method {@link Image.changeChannel}.
*
* The original image is not modified.
*
* @result newImage The grayscale image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.convertToGrayscale();
* }
*/
@Pure
@PythonName("convert_to_grayscale")
@Category(DataScienceCategory.DataProcessingQImage)
fun convertToGrayscale() -> newImage: Image
/**
* Return a new `Image` that has been cropped to a given bounding rectangle.
*
* The original image is not modified.
*
* @param x The x coordinate of the top-left corner of the bounding rectangle.
* @param y The y coordinate of the top-left corner of the bounding rectangle.
* @param width The width of the bounding rectangle.
* @param height The height of the bounding rectangle.
*
* @result newImage The cropped image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.crop(20, 20, 80, 40);
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun crop(
const x: Int,
const y: Int,
const width: Int,
const height: Int
) -> newImage: Image where {
x >= 0,
y >= 0,
width >= 0,
height >= 0
}
/**
* Return a new `Image` where top and bottom are flipped along a horizontal axis.
*
* The original image is not modified.
*
* @result newImage The flipped image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.flipTopAndBottom();
* }
*/
@Pure
@PythonName("flip_top_and_bottom")
@Category(DataScienceCategory.DataProcessingQImage)
fun flipTopAndBottom() -> result: Image
/**
* Return a new `Image` where left and right sides are flipped along a vertical axis.
*
* The original image is not modified.
*
* @result newImage The flipped image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.flipLeftAndRight();
* }
*/
@Pure
@PythonName("flip_left_and_right")
@Category(DataScienceCategory.DataProcessingQImage)
fun flipLeftAndRight() -> result: Image
/**
* Return a new `Image` with an adjusted brightness.
*
* The original image is not modified.
*
* @param factor The brightness factor.
* 1.0 will not change the brightness.
* Below 1.0 will result in a darker image.
* Above 1.0 will resolut in a brighter image.
* Has to be bigger than or equal to 0 (black).
*
* @result newImage The Image with adjusted brightness.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.adjustBrightness(factor = 2.0);
* }
*/
@Pure
@PythonName("adjust_brightness")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustBrightness(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
/**
* Return a new `Image` with noise added to the image.
*
* The original image is not modified.
*
* @param standardDeviation The standard deviation of the normal distribution. Has to be bigger than or equal to 0.
*
* @result newImage The image with added noise.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.addNoise(standardDeviation = 1.0);
* }
*/
@Pure
@PythonName("add_noise")
@Category(DataScienceCategory.DataProcessingQImage)
fun addNoise(
@PythonName("standard_deviation") const standardDeviation: Float
) -> newImage: Image where {
standardDeviation >= 0.0
}
/**
* Return a new `Image` with adjusted contrast.
*
* The original image is not modified.
*
* @param factor If factor > 1, increase contrast of image.
* If factor = 1, no changes will be made.
* If factor < 1, make image greyer.
* Has to be bigger than or equal to 0 (gray).
*
* @result newImage New image with adjusted contrast.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.adjustContrast(factor = 2.0);
* }
*/
@Pure
@PythonName("adjust_contrast")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustContrast(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
/**
* Return a new `Image` with adjusted color balance.
*
* The original image is not modified.
*
* @param factor Has to be bigger than or equal to 0.
* If 0 <= factor < 1, make image greyer.
* If factor = 1, no changes will be made.
* If factor > 1, increase color balance of image.
*
* @result newImage The new, adjusted image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.adjustColorBalance(factor = 2.0);
* }
*/
@Pure
@PythonName("adjust_color_balance")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustColorBalance(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
/**
* Return a blurred version of the image.
*
* The original image is not modified.
*
* @param radius Radius is directly proportional to the blur value. The radius is equal to the amount of pixels united in
* each direction. A radius of 1 will result in a united box of 9 pixels.
*
* @result newImage The blurred image.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.blur(radius = 50);
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun blur(
const radius: Int
) -> newImage: Image where {
radius >= 0
}
/**
* Return a sharpened version of the image.
*
* The original image is not modified.
*
* @param factor If factor > 1, increase the sharpness of the image.
* If factor = 1, no changes will be made.
* If factor < 1, blur the image.
* Has to be bigger than or equal to 0 (blurred).
*
* @result newImage The image sharpened by the given factor.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.sharpen(factor = 5.0);
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun sharpen(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
/**
* Return a new `Image` with colors inverted.
*
* The original image is not modified.
*
* @result newImage The image with inverted colors.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.invertColors();
* }
*/
@Pure
@PythonName("invert_colors")
@Category(DataScienceCategory.DataProcessingQImage)
fun invertColors() -> newImage: Image
/**
* Return a new `Image` that is rotated 90 degrees clockwise.
*
* The original image is not modified.
*
* @result newImage The image rotated 90 degrees clockwise.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.rotateRight();
* }
*/
@Pure
@PythonName("rotate_right")
@Category(DataScienceCategory.DataProcessingQImage)
fun rotateRight() -> newImage: Image
/**
* Return a new `Image` that is rotated 90 degrees counter-clockwise.
*
* The original image is not modified.
*
* @result newImage The image rotated 90 degrees counter-clockwise.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.rotateLeft();
* }
*/
@Pure
@PythonName("rotate_left")
@Category(DataScienceCategory.DataProcessingQImage)
fun rotateLeft() -> newImage: Image
/**
* Return a grayscale version of the image with the edges highlighted.
*
* The original image is not modified.
*
* @result newImage The image with edges found.
*
* @example
* pipeline example {
* val image = Image.fromFile("example.png");
* val newImage = image.findEdges();
* }
*/
@Pure
@PythonName("find_edges")
@Category(DataScienceCategory.DataProcessingQImage)
fun findEdges() -> newImage: Image
}
|
channel
Get the number of channels of the image.
Type: Int
height
Get the height of the image in pixels.
Type: Int
size
Get the ImageSize of the image.
Type: ImageSize
width
Get the width of the image in pixels.
Type: Int
addNoise
Return a new Image with noise added to the image.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
standardDeviation |
Float |
The standard deviation of the normal distribution. Has to be bigger than or equal to 0. |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The image with added noise. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.addNoise(standardDeviation = 1.0);
}
Stub code in Image.sdsstub
| @Pure
@PythonName("add_noise")
@Category(DataScienceCategory.DataProcessingQImage)
fun addNoise(
@PythonName("standard_deviation") const standardDeviation: Float
) -> newImage: Image where {
standardDeviation >= 0.0
}
|
adjustBrightness
Return a new Image with an adjusted brightness.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
factor |
Float |
The brightness factor. 1.0 will not change the brightness. Below 1.0 will result in a darker image. Above 1.0 will resolut in a brighter image. Has to be bigger than or equal to 0 (black). |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The Image with adjusted brightness. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.adjustBrightness(factor = 2.0);
}
Stub code in Image.sdsstub
| @Pure
@PythonName("adjust_brightness")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustBrightness(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
|
adjustColorBalance
Return a new Image with adjusted color balance.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
factor |
Float |
Has to be bigger than or equal to 0. If 0 <= factor < 1, make image greyer. If factor = 1, no changes will be made. If factor > 1, increase color balance of image. |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The new, adjusted image. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.adjustColorBalance(factor = 2.0);
}
Stub code in Image.sdsstub
| @Pure
@PythonName("adjust_color_balance")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustColorBalance(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
|
adjustContrast
Return a new Image with adjusted contrast.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
factor |
Float |
If factor > 1, increase contrast of image. If factor = 1, no changes will be made. If factor < 1, make image greyer. Has to be bigger than or equal to 0 (gray). |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
New image with adjusted contrast. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.adjustContrast(factor = 2.0);
}
Stub code in Image.sdsstub
| @Pure
@PythonName("adjust_contrast")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustContrast(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
|
blur
Return a blurred version of the image.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
radius |
Int |
Radius is directly proportional to the blur value. The radius is equal to the amount of pixels united in each direction. A radius of 1 will result in a united box of 9 pixels. |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The blurred image. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.blur(radius = 50);
}
Stub code in Image.sdsstub
| @Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun blur(
const radius: Int
) -> newImage: Image where {
radius >= 0
}
|
changeChannel
Return a new Image that has the given number of channels.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
channel |
Int |
The new number of channels. 1 will result in a grayscale image. |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The image with the given number of channels. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.changeChannel(channel = 1);
}
Stub code in Image.sdsstub
| @Pure
@PythonName("change_channel")
@Category(DataScienceCategory.DataProcessingQImage)
fun changeChannel(
channel: Int
) -> newImage: Image
|
convertToGrayscale
Return a new Image that is converted to grayscale.
The new image will have the same amount of channels as the original image. If you want to change the amount of
channels used, please use the method Image.changeChannel.
The original image is not modified.
Results:
| Name |
Type |
Description |
newImage |
Image |
The grayscale image. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.convertToGrayscale();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("convert_to_grayscale")
@Category(DataScienceCategory.DataProcessingQImage)
fun convertToGrayscale() -> newImage: Image
|
crop
Return a new Image that has been cropped to a given bounding rectangle.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
x |
Int |
The x coordinate of the top-left corner of the bounding rectangle. |
- |
y |
Int |
The y coordinate of the top-left corner of the bounding rectangle. |
- |
width |
Int |
The width of the bounding rectangle. |
- |
height |
Int |
The height of the bounding rectangle. |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The cropped image. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.crop(20, 20, 80, 40);
}
Stub code in Image.sdsstub
| @Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun crop(
const x: Int,
const y: Int,
const width: Int,
const height: Int
) -> newImage: Image where {
x >= 0,
y >= 0,
width >= 0,
height >= 0
}
|
findEdges
Return a grayscale version of the image with the edges highlighted.
The original image is not modified.
Results:
| Name |
Type |
Description |
newImage |
Image |
The image with edges found. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.findEdges();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("find_edges")
@Category(DataScienceCategory.DataProcessingQImage)
fun findEdges() -> newImage: Image
|
flipLeftAndRight
Return a new Image where left and right sides are flipped along a vertical axis.
The original image is not modified.
Results:
| Name |
Type |
Description |
result |
Image |
- |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.flipLeftAndRight();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("flip_left_and_right")
@Category(DataScienceCategory.DataProcessingQImage)
fun flipLeftAndRight() -> result: Image
|
flipTopAndBottom
Return a new Image where top and bottom are flipped along a horizontal axis.
The original image is not modified.
Results:
| Name |
Type |
Description |
result |
Image |
- |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.flipTopAndBottom();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("flip_top_and_bottom")
@Category(DataScienceCategory.DataProcessingQImage)
fun flipTopAndBottom() -> result: Image
|
invertColors
Return a new Image with colors inverted.
The original image is not modified.
Results:
| Name |
Type |
Description |
newImage |
Image |
The image with inverted colors. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.invertColors();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("invert_colors")
@Category(DataScienceCategory.DataProcessingQImage)
fun invertColors() -> newImage: Image
|
resize
Return a new Image that has been resized to a given size.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
newWidth |
Int |
The new width of the image. |
- |
newHeight |
Int |
The new height of the image. |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The image with the given width and height. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.resize(newWidth = 100, newHeight = 50);
}
Stub code in Image.sdsstub
| @Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun resize(
@PythonName("new_width") const newWidth: Int,
@PythonName("new_height") const newHeight: Int
) -> newImage: Image where {
newWidth >= 0,
newHeight >= 0
}
|
rotateLeft
Return a new Image that is rotated 90 degrees counter-clockwise.
The original image is not modified.
Results:
| Name |
Type |
Description |
newImage |
Image |
The image rotated 90 degrees counter-clockwise. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.rotateLeft();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("rotate_left")
@Category(DataScienceCategory.DataProcessingQImage)
fun rotateLeft() -> newImage: Image
|
rotateRight
Return a new Image that is rotated 90 degrees clockwise.
The original image is not modified.
Results:
| Name |
Type |
Description |
newImage |
Image |
The image rotated 90 degrees clockwise. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.rotateRight();
}
Stub code in Image.sdsstub
| @Pure
@PythonName("rotate_right")
@Category(DataScienceCategory.DataProcessingQImage)
fun rotateRight() -> newImage: Image
|
sharpen
Return a sharpened version of the image.
The original image is not modified.
Parameters:
| Name |
Type |
Description |
Default |
factor |
Float |
If factor > 1, increase the sharpness of the image. If factor = 1, no changes will be made. If factor < 1, blur the image. Has to be bigger than or equal to 0 (blurred). |
- |
Results:
| Name |
Type |
Description |
newImage |
Image |
The image sharpened by the given factor. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
val newImage = image.sharpen(factor = 5.0);
}
Stub code in Image.sdsstub
| @Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun sharpen(
const factor: Float
) -> newImage: Image where {
factor >= 0.0
}
|
toJpegFile
Save the image as a JPEG file.
Parameters:
| Name |
Type |
Description |
Default |
path |
String |
The path to the JPEG file. |
- |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
image.toJpegFile("output.jpeg");
}
Stub code in Image.sdsstub
| @Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_jpeg_file")
@Category(DataScienceCategory.DataExport)
fun toJpegFile(
path: String
)
|
toPngFile
Save the image as a PNG file.
Parameters:
| Name |
Type |
Description |
Default |
path |
String |
The path to the PNG file. |
- |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
image.toPngFile("output.png");
}
Stub code in Image.sdsstub
| @Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_png_file")
@Category(DataScienceCategory.DataExport)
fun toPngFile(
path: String
)
|
fromFile
Create an image from a file.
Parameters:
| Name |
Type |
Description |
Default |
path |
String |
The path to the image file. |
- |
Results:
| Name |
Type |
Description |
image |
Image |
The image. |
Examples:
pipeline example {
val image = Image.fromFile("example.png");
}
Stub code in Image.sdsstub
| @Impure([ImpurityReason.FileReadFromParameterizedPath("path")])
@PythonName("from_file")
@Category(DataScienceCategory.DataImport)
static fun fromFile(
path: String
) -> image: Image
|