Image Plans (Paternova™ v.0.9.9)
An image is a table of pixel colors, with each pixel represented by four numbers corresponding to the red, green, blue, and alpha channels. The following functions, or "plans," can be used to create, modify, calculate, read, write, and otherwise manipulate images in Paternova.
Get an Image
These plans create an image using the information provided by the user.
Custom Image
Plan to generate a custom image.
Description
This plan generates an image based on the specified image x. The image parameter can be specified either as an image expression or as a reference to the output image in another cell. When an image expression is provided, this plan produces the output image by evaluating the image expression x.
The image expression parser supports the following expressions:
- box(width, height, color)
- ellipse(width, height, color)
- line(width, height, color)
- flower(width, height)
Example
| x = {box(10,10,black)} | ⇒ | {...} |
| x = {circle(22,#A0C074)} | ⇒ | {...} |
| x = {ellipse(20,10)} | ⇒ | {...} |
| x = {line(120,-100,red)} | ⇒ | {...} |
Fill Image
Plan to generate a filled image.
Description
This plan fills a w×h image with the specified color consisting of the color channels {red, green, blue, alpha}, where each channel value ranges from 0 to 255.
Example
| w = {100}; | h = {50}; | color = {160,192,116,255} | ⇒ | {...} |
Image of Text
Plan to plot a text.
Description
This plan generates a w×h image containing centered text, with the specified background color, font description, and pen color.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {160,192,116,255}; | font = {}; | text = {Hello World!} | ⇒ | {...} |
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {160,192,116,255}; | font = {Helvetica,12}; | text = {Hello World!} | ⇒ | {...} |
Image of Points
Plan to plot points.
Description
This plan generates a w×h image containing points A (Ax, Ay) with a given background color. Each point is specified by a pen color and a pen width. For each available k, a point is plotted at (Ax[k], Ay[k]) with pen width[k] and pen color[4k,4k+1,4k+2,4k+3] (RGBA). If the corresponding values are not available, the last pen width and pen color are used.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255, 0,0,0,255, 160,192,116,255}; | pen width = {0,0,2}; | Ax = {7,20,60}; | Ay = {15,5,42} | ⇒ | {...} |
Image of Lines
Plan to plot lines.
Description
This plan generates a w×h image containing straight lines between points A (Ax, Ay) and B (Bx, By) with a given background color. Each line is specified by a pen color and a pen width. For each available k, a line is plotted between (Ax[k], Ay[k]) and (Bx[k], By[k]) with pen width[k] and pen color[4k,4k+1,4k+2,4k+3] (RGBA). If the corresponding values are not available, the last pen width and pen color are used.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255, 0,0,0,255, 160,192,116,255}; | pen width = {0,0,2}; | Ax = {7,20,60}; | Ay = {15,5,42}; | Bx = {3,3,3}; | By = {3,3,3} | ⇒ | {...} |
Image of Bézier Spline
Plan to plot a Bézier curve.
Description
This plan generates a w×h image containing a cubic Bézier spline strip between points A (Ax, Ay), with control points C1 (C1x, C1y) and C2 (C2x, C2y). The plan parameters also include the background color, fill color, pen color, and pen width. The cubic spline is plotted between (Ax[k], Ay[k]) and (Ax[k+1], Ay[k+1]) with control points (C1x[k], C1y[k]) and (C2x[k], C2y[k]) for each available k.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | fill color = {160,192,116,255}; | pen width = {2}; | Ax = {7,20,60}; | Ay = {15,5,42}; | C1x = {7,-3}; | C1y = {12,-3}; | C2x = {-5,0}; | C2y = {-5,0} | ⇒ | {...} |
Image of Rectangles
Plan to plot rectangles.
Description
This plan generates a w×h image containing rectangles defined by corners A (Ax, Ay) and B (Bx, By), with rounded corners of radii rx and ry, and a given background color. Each rectangle is specified by a fill color, a pen color, and a pen width. For each available k, a rectangle is plotted between (Ax[k], Ay[k]) and (Bx[k], By[k]) with pen width[k], pen color[4k,4k+1,4k+2,4k+3] (RGBA), fill color[4k, 4k+1, 4k+2, 4k+3](RGBA), and corner radii rx[x] and ry[k]. If the corresponding values are not available, the last pen width, pen color, fill color, rx, and ry are used.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | fill color = {160,192,116,255}; | pen width = {2,0}; | Ax = {7,20,60}; | Ay = {15,5,42}; | Bx = {10,55,5}; | By = {20,30,30}; | rx = {1,2,4}; | ry = {1,5,2} | ⇒ | {...} |
Image of Polygon
Plan to plot a polygon.
Description
This plan generates a w×h image containing a polygon between the corners A (Ax, Ay), with the specified background color, fill color, pen color, and pen width.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | fill color = {160,192,116,255}; | pen width = {2}; | Ax = {10,20,80,55,30}; | Ay = {10,5,12,40,35} | ⇒ | {...} |
Image of Arcs
Plan to plot arcs.
Description
This plan generates a w×h image containing arcs enclosed within rectangles, defined by the corners A (Ax, Ay) and B (Bx, By), and a given background color. Each arc is specified by a start angle, a span angle, a pen color, and a pen width. For each available k, an arc is plotted in the rectangle defined by (Ax[k], Ay[k]) and (Bx[k], By[k]), starting at start angle[k] and spanning span angle[k], using pen width[k] and pen color[4k,4k+1,4k+2,4k+3](RGBA). If the corresponding values are not available, the last pen width and pen color are used. Angles are given in degrees, with positive angles measured counterclockwise and zero at the 3 o’clock position.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | pen width = {2,0}; | Ax = {7,20,60}; | Ay = {15,5,42}; | Bx = {10,55,5}; | By = {20,30,30}; | start angle = {0,90,180}; | span angle = {180,360,-90} | ⇒ | {...} |
Image of Chords
Plan to plot chords.
Description
This plan generates a w×h image containing chords enclosed within rectangles, defined by the corners A (Ax, Ay) and B (Bx, By), and a given background color. Each chord is specified by a start angle, a span angle, a fill color, a pen color, and a pen width. For each available k, a chord is plotted in the rectangle defined by (Ax[k], Ay[k]) and (Bx[k], By[k]), starting at start angle[k] and spanning span angle[k], using pen width[k], pen color[4k,4k+1,4k+2,4k+3] (RGBA), and fill color[4k,4k+1,4k+2,4k+3] (RGBA). If the corresponding values are not available, the last pen width, pen color, and fill color are used. Angles are given in degrees, with positive angles measured counterclockwise and zero at the 3 o’clock position.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | fill color = {160,192,116,255}; | pen width = {2,0}; | Ax = {7,20,60}; | Ay = {15,5,42}; | Bx = {10,55,5}; | By = {20,30,30}; | start angle = {0,90,180}; | span angle = {180,360,-90} | ⇒ | {...} |
Image of Pies
Plan to plot pies.
Description
This plan generates a w×h image containing pies enclosed within rectangles, defined by the corners A (Ax, Ay) and B (Bx, By), and a given background color. Each pie is specified by a start angle, a span angle, a fill color, a pen color, and a pen width. For each available k, a pie is plotted in the rectangle defined by (Ax[k], Ay[k]) and (Bx[k], By[k]), starting at start angle[k] and spanning span angle[k], using pen width[k], pen color[4k,4k+1,4k+2,4k+3] (RGBA), and fill color[4k,4k+1,4k+2,4k+3] (RGBA). If the corresponding values are not available, the last pen width, pen color, and fill color are used. Angles are given in degrees, with positive angles measured counterclockwise and zero at the 3 o’clock position.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | fill color = {160,192,116,255}; | pen width = {2,0}; | Ax = {7,20,60}; | Ay = {15,5,42}; | Bx = {10,55,5}; | By = {20,30,30}; | start angle = {0,90,180}; | span angle = {180,360,-90} | ⇒ | {...} |
Image of Ellipses
Plan to plot ellipses.
Description
This plan generates a w×h image containing ellipses centered at A (Ax, Ay) with specified radii rx and ry, and a given background color. Each ellipse is specified by a fill color, a pen color, and a pen width. For each available k, an ellipse is plotted with center (Ax[k], Ay[k]), radii rx[k] and ry[k], pen width[k], pen color[4k,4k+1,4k+2,4k+3] (RGBA), and fill color[4k,4k+1,4k+2,4k+3] (RGBA). If the corresponding values are not available, the last pen width, pen color, and fill color are used.
Example
| w = {100}; | h = {50}; | background color = {255,255,255,255}; | pen color = {0,0,0,255}; | fill color = {160,192,116,255}; | pen width = {2,0}; | Ax = {10,20,60}; | Ay = {10,35,12}; | rx = {2,15,8}; | ry = {4,15,8} | ⇒ | {...} |
Import From Image File
Plan to import an image from an image file.
Description
This plan automatically detects the image format from the file at the given file name and imports it.
Example
| file name = {tests\testimage.png} | ⇒ | {...} |
Import From BMP File
Plan to import an image from a BMP file.
Description
This plan imports an image from a Windows Bitmap (BMP) file with the given file name.
Example
| file name = {tests\testimage.bmp} | ⇒ | {...} |
Import From GIF File
Plan to import an image from a GIF file.
Description
This plan imports an image from a Graphic Interchange Format (GIF) file with the given file name.
Example
| file name = {tests\flower.gif} | ⇒ | {...} |
Import From JPG File
Plan to import an image from a JPG file.
Description
This plan imports an image from a Joint Photographic Experts Group (JPG) file with the given file name.
Example
| file name = {tests\testimage.jpg} | ⇒ | {...} |
Import From PNG File
Plan to import an image from a PNG file.
Description
This plan imports an image from a Portable Network Graphics (PNG) file with the given file name.
Example
| file name = {tests\testimage.png} | ⇒ | {...} |
Import From PBM File
Plan to import an image from a PBM file.
Description
This plan imports an image from a Portable Bitmap (PBM) file with the given file name.
Example
| file name = {tests\sierpinski.pbm} | ⇒ | {...} |
Import From PGM File
Plan to import an image from a PGM file.
Description
This plan imports an image from a Portable Gray Map (PGM) file with the given file name.
Example
| file name = {tests\buffalo.pgm} | ⇒ | {...} |
Import From PPM File
Plan to import an image from a PPM file.
Description
This plan imports an image from a Portable Pixel Map (PPM) file with the given file name.
Example
| file name = {tests\blackbuck.ppm} | ⇒ | {...} |
Import From XBM File
Plan to import an image from an XBM file.
Description
This plan imports an image from an X11 Bitmap (XBM) file with the given file name.
Example
| file name = {tests\testimage.xbm} | ⇒ | {...} |
Import From XPM File
Plan to import an image from an XPM file.
Description
This plan imports an image from an X11 Pixel Map (XPM) file with the given file name.
Example
| file name = {tests\teapot.xpm} | ⇒ | {...} |
Import From Video File
Plan to import an image from a video file.
Description
This plan imports an image from the specified frame number in a video file with the given file name and api. The parameter api is the OpenCV VideoCapture API backend identifier. If api is set to 0, the available backend is auto-detected.
Example
| file name = {tests\face.avi}; | api = {0}; | frame number = {3} | ⇒ | {...} |
Import From Camera
Plan to capture an image from a streaming device.
Description
This plan captures an image from a streaming device with the specified device id and api. Setting the device id to 0 captures from the default camera. The parameter api is the OpenCV VideoCapture API backend identifier. If api is set to 0, the available backend is auto-detected.
Please note that cameras may require capturing several frames to flush their buffer before producing a clear image.
Example
| device id = {0}; | api = {0} | ⇒ | {...} |
Import From Network
Plan to import an image from network.
Description
This plan requests and imports an image from a network address.
Example
| address = {https://picsum.photos/200/300} | ⇒ | {...} |
Convert Arrays Along Columns - Channels
Plan to use four arrays to generate the pixel color channels column by column.
Description
This plan generates an image from the arrays r, g, b, and a by filling columns of height h. The red channel of each pixel is assigned a value from array r, one after another. Similarly, the green channel of each pixel is assigned a value from array g, the blue channel from b, and the alpha channel from a. Once all values in array r, g, b, or a have been assigned, the scalars r₀, g₀, b₀, or a₀ are used, respectively, for the red, green, blue, or alpha channels. Color channel values are limited to the range of 0 to 255.
Example
| r = {}; | g = {0,255,0,255,0,0,0}; | b = {}; | a = {}; | h = {3}; | r₀ = {0}; | g₀ = {0}; | b₀ = {0}; | a₀ = {255} | ⇒ | {...} |
| r = {0,100,100,0,100,100,0}; | g = {}; | b = {0,255,0,255,0,0,0}; | a = {}; | h = {4}; | r₀ = {255}; | g₀ = {0}; | b₀ = {0}; | a₀ = {255} | ⇒ | {...} |
Convert Arrays Along Rows - Channels
Plan to use four arrays to generate the pixel color channels row by row.
Description
This plan generates an image from the arrays r, g, b, and a by filling rows of width w. The red channel of each pixel is assigned a value from array r, one after another. Similarly, the green channel of each pixel is assigned a value from array g, the blue channel from b, and the alpha channel from a. Once all values in array r, g, b, or a have been assigned, the scalars r₀, g₀, b₀, or a₀ are used, respectively, for the red, green, blue, or alpha channels. Color channel values are limited to the range of 0 to 255.
Example
| r = {}; | g = {0,255,0,255,0,0,0}; | b = {}; | a = {}; | w = {3}; | r₀ = {0}; | g₀ = {0}; | b₀ = {0}; | a₀ = {255} | ⇒ | {...} |
| r = {0,100,100,0,100,100,0}; | g = {}; | b = {0,255,0,255,0,0,0}; | a = {}; | w = {4}; | r₀ = {255}; | g₀ = {0}; | b₀ = {0}; | a₀ = {255} | ⇒ | {...} |
Convert Array Along Columns - RGBA
Plan to use an array to generate the pixel colors column by column.
Description
This plan generates an image from the the array x by filling columns of height h. x[0], x[1], x[2], and x[3] are assigned to the red, green, blue, and alpha channels of the first pixel, respectively. x[4], x[5], x[6], and x[7] are assigned to the channels of the second pixel, and so on. Color channel values are limited to the range of 0 to 255. Once all values in array x have been assigned, the remaining pixels are painted with the RGBA color c₀.
Example
| x = {0,0,0,255,0,255,0,255,0,0,0,255,0,255,0,255,0,0,0,255,0,0,0,255,0,0,0,255}; | h = {3}; | c₀ = {0,0,0,255} | ⇒ | {...} |
| x = {0,0,0,255,100,0,255,255,100,0,0,255,0,0,255,255,100,0,0,255,100,0,0,255,0,0,0,255}; | h = {4}; | c₀ = {255,0,0,255} | ⇒ | {...} |
Convert Array Along Rows - RGBA
Plan to use an array to generate the pixel colors row by row.
Description
This plan generates an image from the the array x by filling rows of width w. x[0], x[1], x[2], and x[3] are assigned to the red, green, blue, and alpha channels of the first pixel, respectively. x[4], x[5], x[6], and x[7] are assigned to the channels of the second pixel, and so on. Color channel values are limited to the range of 0 to 255. Once all values in array x have been assigned, the remaining pixels are painted with the RGBA color c₀.
Example
| x = {0,0,0,255,0,255,0,255,0,0,0,255,0,255,0,255,0,0,0,255,0,0,0,255,0,0,0,255}; | w = {3}; | c₀ = {0,0,0,255} | ⇒ | {...} |
| x = {0,0,0,255,100,0,255,255,100,0,0,255,0,0,255,255,100,0,0,255,100,0,0,255,0,0,0,255}; | w = {4}; | c₀ = {255,0,0,255} | ⇒ | {...} |
Convert Matrix
Plan to generate an image from a matrix.
Description
This plan generates an image from the matrix x. The color channels of each pixel are set by evaluating the expressions r(x, i, j) for the red channel, g(x, i, j) for the green channel, b(x, i, j) for the blue channel, and a(x, i, j) for the alpha channel. Here, i and j are the row and column indices of the element, counted from 0; and x is the element at row i (the y-coordinate) and column j (the x-coordinate). Only the real parts of the results of these four expressions are used to compute the color channel values. Color channels are limited to the range of 0 to 255.
The complex expression parser supports the following:
- Complex number representations: a, I, bI, and a+bI, where a and b are floating-point numbers, and I=√(-1).
- Complex operations: real, imag, abs, arg, and conj.
- Basic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), and exponentiation (^).
- Exponentiation functions: exp, pow, and sqrt.
- Logarithmic functions: exp and log (natural logarithm with the branch cut along the negative real axis).
- Trigonometric functions: sin, cos, tan, asin, acos, and atan.
- Hyperbolic functions: sinh, cosh, tanh, asinh, acosh, and atanh.
- Constants: pi and e.
Example
| x = {1,2,6;2,4,0;6,0,2}; | r = {x*40}; | g = {x*48}; | b = {x*29}; | a = {255} | ⇒ | {...} |
| x = {8,0,0,0,7; 0,0,0,0,0; 0,0,0,0,0; 0,0,0,0,0; 5,0,0,0,6}; | r = {30*x}; | g = {70*abs((i-2)+(j-2))}; | b = {30*x}; | a = {255} | ⇒ | {...} |
Convert Text
Plan to generate an image from a text.
Description
This plan generates an image from the image expression text x.
The image expression parser supports the following expressions:
- box(width, height, color)
- ellipse(width, height, color)
- line(width, height, color)
- flower(width, height)
Example
| x = {box(10,10,black)} | ⇒ | {...} |
| x = {circle(22,#A0C074)} | ⇒ | {...} |
| x = {ellipse(20,10)} | ⇒ | {...} |
| x = {line(120,-100,red)} | ⇒ | {...} |
OpenAI - Image Generation
Plan to generate an image with OpenAI API.
Description
This plan generates a w×h image based on a prompt using the OpenAI API. Requests are authenticated with an api key.
Notes:
- To acquire an api key, go to https://platform.openai.com.
- To learn more about the API parameters, visit https://platform.openai.com/docs/api-reference/images/create.
- This plan requests data from OpenAI's servers by sharing the plan parameters. The Terms of Use for OpenAI are available at https://openai.com/policies/terms-of-use.
- You may need to increase the network timeout (Preferences > Network Timeout) to allow enough time for the API response to arrive.
- A corresponding plan to generate the complete API response is available under Text Plans/Get/3rd-Party Importers - Raw Response.
Example
| w = {1024}; | h = {1024}; | prompt = {A photograph of a fancy cat with a hat.}; | api key = {...} | ⇒ | {...} |
Google Maps - Image Generation
Plan to generate an image with Google Maps API.
Description
This plan generates a w×h static map, defined by a center location and a zoom level, using the Google Maps Static API. Requests are authenticated with an api key. Location parameters can be either an address or a "latitude, longitude" pair. The zoom level is a numerical value, with the smallest value, 0, displaying the entire Earth.
Several optional parameters are supported: visible specifies one or more locations, separated by a pipe ("|") character, that should remain visible on the map; and maptype defines the type of map to generate. Possible values for maptype include roadmap, satellite, hybrid, and terrain. A digital signature may also be required by the web version.
Notes:
- To acquire an api key, go to https://developers.google.com/maps/documentation/javascript/get-api-key.
- To learn more about the API parameters, visit https://developers.google.com/maps/documentation/maps-static/start?hl=en.
- This plan requests data from Google Maps's servers by sharing the plan parameters. The Terms of Use for Google Maps are available at https://cloud.google.com/maps-platform/terms?hl=en.
- You may need to increase the network timeout (Preferences > Network Timeout) to allow enough time for the API response to arrive.
Example
| w = {1024}; | h = {1024}; | center = {Toronto, Queen Street and University Avenue}; | zoom = {16}; | api key = {...} | ⇒ | {...} |
Rearrange an Image
These plans produce an image by rearranging another image.
Copy Image
Plan to copy an image.
Description
This plan copies all the pixels in the image x.
Example
| x = {circle(20,blue)} | ⇒ | {...} |
Replicate Columns
Plan to replicate an image in width.
Description
This plan replicates the image x in width by repeating each column p times, and then replicates the resulting image q times.
Example
| x = {circle(20,blue)}; | p = {2}; | q = {3} | ⇒ | {...} |
Replicate Rows
Plan to replicate an image in height.
Description
This plan replicates the image x in height by repeating each row p times, and then replicates the resulting image q times.
Example
| x = {circle(20,blue)}; | p = {2}; | q = {3} | ⇒ | {...} |
Resize Image
Plan to resize an image.
Description
This plan resizes a copy of image x to w×h, without altering its existing pixels. If necessary, it trims the sides or pads them with the specified color. If w or h is not specified, that dimension is not modified.
Example
| x = {circle(20,blue)}; | w = {10}; | color = {160,192,116,255} | ⇒ | {...} | |
| x = {circle(20,blue)}; | w = {25}; | color = {160,192,116,255} | ⇒ | {...} | |
| x = {circle(20,blue)}; | h = {10}; | color = {160,192,116,255} | ⇒ | {...} | |
| x = {circle(20,blue)}; | h = {25}; | color = {160,192,116,255} | ⇒ | {...} | |
| x = {circle(20,blue)}; | w = {10}; | h = {25}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {circle(20,blue)}; | w = {25}; | h = {25}; | color = {160,192,116,255} | ⇒ | {...} |
Mirror Horizontally
Plan to mirror an image horizontally.
Description
This plan creates a copy of image x and mirrors it horizontally (about the vertical axis), so that the pixels in each row are reversed.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Mirror Vertically
Plan to mirror an image vertically.
Description
This plan creates a copy of image x and mirrors it vertically (about the horizontal axis), so that the pixels in each column are reversed.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Mirror Diagonally
Plan to mirror an image diagonally.
Description
This plan creates a copy of image x and mirrors it diagonally (about the main skew diagonal axis), so that the main skew diagonal remains unchanged.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Mirror Off-Diagonally
Plan to mirror an image off-diagonally.
Description
This plan creates a copy of image x and mirrors it off-diagonally (about the main diagonal axis), so that the main diagonal remains unchanged.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Rotate +90°
Plan to rotate an image by +90° (90°CCW).
Description
This plan rotates a copy of image x by 90° counterclockwise by moving the upper-right corner pixel to the upper-left corner, and so on.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Rotate -90°
Plan to rotate an image by -90° (90°CW).
Description
This plan rotates a copy of image x by 90° clockwise by moving the upper-right corner pixel to the lower-right corner, and so on.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Rotate 180°
Plan to rotate an image by 180°.
Description
This plan rotates a copy of image x by 180° by moving the upper-right corner pixel to the lower-left corner, and so on.
Example
| x = {line(10,20,blue)} | ⇒ | {...} |
| x = {flower(100,100)} | ⇒ | {...} |
Copy Pixels
Plan to copy pixels.
Description
This plan copies the pixel of the image x at column x₀[k] and row y₀[k] for each k. When the lengths of the arrays x₀ and y₀ are different, the last value of the shorter array is used. The pixels are copied into a column image.
Example
| x = {line(10,20,blue)}; | x₀ = {5,4,3,2,1}; | y₀ = {1,2} | ⇒ | {...} |
Subimage by Inclusion
Plan to create a subimage by keeping rows and columns.
Description
This plan creates a subimage of image x containing the pixels at the specified columns x₀ and rows y₀.
Example
| x = {line(10,20,blue)}; | x₀ = {5,4,3,2,1}; | y₀ = {1,2} | ⇒ | {...} |
Subimage by Exclusion
Plan to create a subimage by removing rows and columns.
Description
This plan creates a subimage of image x by removing the pixels in the specified columns x₀ or rows y₀.
Example
| x = {line(10,20,blue)}; | x₀ = {5,4,3,2,1}; | y₀ = {1,2} | ⇒ | {...} |
Subimage with Columns
Plan to create a subimage of columns.
Description
This plan creates a subimage of image x using the columns with indices specified in x₀.
Example
| x = {line(10,20,blue)}; | x₀ = {5,4,3,2,1} | ⇒ | {...} |
Subimage with Rows
Plan to create a subimage of rows.
Description
This plan creates a subimage of image x using the rows with indices specified in y₀.
Example
| x = {line(10,20,blue)}; | y₀ = {5,4,3,2,1} | ⇒ | {...} |
Crop From Top Left
Plan to crop a subimage from top left.
Description
This plan copies a w×h subimage of image x, starting from the pixel at column x₀ and row y₀, counted from the upper-left corner. If the cropped window does not fit entirely within x, any area outside the image is omitted.
Example
| x = {line(10,20,blue)}; | w = {8}; | h = {20}; | x₀ = {3}; | y₀ = {0} | ⇒ | {...} |
| x = {flower(100,100)}; | w = {80}; | h = {50}; | x₀ = {20}; | y₀ = {50} | ⇒ | {...} |
Crop From Top Right
Plan to crop a subimage from top right.
Description
This plan copies a w×h subimage of image x, starting from the pixel at column x₀ and row y₀, counted from the upper-right corner. If the cropped window does not fit entirely within x, any area outside the image is omitted.
Example
| x = {line(10,20,blue)}; | w = {8}; | h = {20}; | x₀ = {3}; | y₀ = {0} | ⇒ | {...} |
| x = {flower(100,100)}; | w = {80}; | h = {50}; | x₀ = {20}; | y₀ = {50} | ⇒ | {...} |
Crop From Bottom Left
Plan to crop a subimage from bottom left.
Description
This plan copies a w×h subimage of image x, starting from the pixel at column x₀ and row y₀, counted from the lower-left corner. If the cropped window does not fit entirely within x, any area outside the image is omitted.
Example
| x = {line(10,20,blue)}; | w = {8}; | h = {20}; | x₀ = {3}; | y₀ = {0} | ⇒ | {...} |
| x = {flower(100,100)}; | w = {80}; | h = {50}; | x₀ = {20}; | y₀ = {50} | ⇒ | {...} |
Crop From Bottom Right
Plan to crop a subimage from bottom right.
Description
This plan copies a w×h subimage of image x, starting from the pixel at column x₀ and row y₀, counted from the lower-right corner. If the cropped window does not fit entirely within x, any area outside the image is omitted.
Example
| x = {line(10,20,blue)}; | w = {8}; | h = {20}; | x₀ = {3}; | y₀ = {0} | ⇒ | {...} |
| x = {flower(100,100)}; | w = {80}; | h = {50}; | x₀ = {20}; | y₀ = {50} | ⇒ | {...} |
Crop From Center
Plan to crop a subimage about its center.
Description
This plan copies a w×h subimage of image x, with a gap of x₀ columns and y₀ rows between the centers. Setting x₀=y₀=0 centers the subimage. When x₀>0, the subimage is shifted to the right, and when y₀>0, it is shifted downward. If the cropped window does not fit entirely within x, any area outside the image is omitted.
Example
| x = {line(10,20,blue)}; | w = {8}; | h = {20}; | x₀ = {3}; | y₀ = {0} | ⇒ | {...} |
| x = {flower(100,100)}; | w = {80}; | h = {50}; | x₀ = {20}; | y₀ = {50} | ⇒ | {...} |
Remove Columns From Left
Plan to remove columns at indices counted from left.
Description
This plan removes N[k] columns from a copy of image x, starting from column x₀[k], counted from the left for each k. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | x₀ = {2,0}; | N = {3,1} | ⇒ | {...} |
Remove Columns From Right
Plan to remove columns at indices counted from right.
Description
This plan removes N[k] columns from a copy of image x, starting from column x₀[k], counted from the right for each k. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | x₀ = {2,0}; | N = {3,1} | ⇒ | {...} |
Remove Rows From Top
Plan to remove rows at indices counted from top.
Description
This plan removes N[k] rows from a copy of image x, starting from row y₀[k], counted from the top for each k. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | y₀ = {2,0}; | N = {3,1} | ⇒ | {...} |
Remove Rows From Bottom
Plan to remove rows at indices counted from bottom.
Description
This plan removes N[k] rows from a copy of image x, starting from row y₀[k], counted from the bottom for each k. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | y₀ = {2,0}; | N = {3,1} | ⇒ | {...} |
Swap Pixels
Plan to swap image pixels.
Description
This plan swaps the pixels at coordinates (x1, y1) with the pixels at coordinates (x2, y2) in a copy of image x. The pixel at coordinates (x1[k], y1[k]) is swapped with the pixel at coordinates (x2[k], y2[k]) for each k.
Example
| x = {line(10,20,blue)}; | x1 = {1,2,3}; | y1 = {0,1,2}; | x2 = {0,1,2}; | y2 = {1,2,3} | ⇒ | {...} |
Swap Columns
Plan to swap image columns.
Description
This plan swaps the pixels in columns x1 with the pixels in columns x2 in a copy of image x. The pixels in column x1[k] are swapped with the pixels in column x2[k] for each k.
Example
| x = {line(10,20,blue)}; | x1 = {1,2,3}; | x2 = {0,1,2} | ⇒ | {...} |
Swap rows
Plan to swap image rows.
Description
This plan swaps the pixels in rows y1 with the pixels in rows y2 in a copy of image x. The pixels in row y1[k] are swapped with the pixels in row y2[k] for each k.
Example
| x = {line(10,20,blue)}; | y1 = {1,2,3}; | y2 = {0,1,2} | ⇒ | {...} |
Insert Columns From Left
Plan to insert columns at indices counted from left.
Description
This plan inserts N[k] columns in a copy of image x, each painted with the specified color, just before column x₀[k], counted from the left, for each k. If there are not enough RGBA colors available, the last color is used. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | x₀ = {0,2,3}; | N = {2,1}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,blue)}; | x₀ = {0,2,0,3}; | N = {2,1,3}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Insert Columns From Right
Plan to insert columns at indices counted from right.
Description
This plan inserts N[k] columns in a copy of image x, each painted with the specified color, just before column x₀[k], counted from the right, for each k. If there are not enough RGBA colors available, the last color is used. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | x₀ = {0,2,3}; | N = {2,1}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,blue)}; | x₀ = {0,2,0,3}; | N = {2,1,3}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Insert Rows From Top
Plan to insert rows at indices counted from top.
Description
This plan inserts N[k] rows in a copy of image x, each painted with the specified color, just before row y₀[k], counted from the top, for each k. If there are not enough RGBA colors available, the last color is used. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | y₀ = {0,2,3}; | N = {2,1}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,blue)}; | y₀ = {0,2,0,3}; | N = {2,1,3}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Insert Rows From Bottom
Plan to insert rows at indices counted from bottom.
Description
This plan inserts N[k] rows in a copy of image x, each painted with the specified color, just before row y₀[k], counted from the bottom, for each k. If there are not enough RGBA colors available, the last color is used. The last value in N is used when k is out of bounds.
Example
| x = {line(10,20,blue)}; | y₀ = {0,2,3}; | N = {2,1}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,blue)}; | y₀ = {0,2,0,3}; | N = {2,1,3}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Trim Sides by Color
Plan to trim all sides of an image with a given color.
Description
This plan removes columns and rows from all four sides of a copy of image x, as long as every pixel in the columns and rows being removed matches the specified color.
Example
| x = {flower(100,100)}; | color = {0,0,0,0} | ⇒ | {...} |
| x = {box(100,100,black)}; | color = {0,0,0,255} | ⇒ | {...} |
Trim Left by Color
Plan to trim the left side of an image with a given color.
Description
This plan removes columns from the left side of a copy of image x, as long as every pixel in the columns being removed matches the specified color.
Example
| x = {flower(100,100)}; | color = {0,0,0,0} | ⇒ | {...} |
| x = {box(100,100,black)}; | color = {0,0,0,255} | ⇒ | {...} |
Trim Right by Color
Plan to trim the right side of an image with a given color.
Description
This plan removes columns from the right side of a copy of image x, as long as every pixel in the columns being removed matches the specified color.
Example
| x = {flower(100,100)}; | color = {0,0,0,0} | ⇒ | {...} |
| x = {box(100,100,black)}; | color = {0,0,0,255} | ⇒ | {...} |
Trim Top by Color
Plan to trim the top side of an image with a given color.
Description
This plan removes rows from the top of a copy of image x, as long as every pixel in the rows being removed matches the specified color.
Example
| x = {flower(100,100)}; | color = {0,0,0,0} | ⇒ | {...} |
| x = {box(100,100,black)}; | color = {0,0,0,255} | ⇒ | {...} |
Trim Bottom by Color
Plan to trim the bottom side of an image with a given color.
Description
This plan removes rows from the bottom of a copy of image x, as long as every pixel in the rows being removed matches the specified color.
Example
| x = {flower(100,100)}; | color = {0,0,0,0} | ⇒ | {...} |
| x = {box(100,100,black)}; | color = {0,0,0,255} | ⇒ | {...} |
Trim Sides by Top Left Color
Plan to trim all sides of an image with the same color as upper-left corner.
Description
This plan removes columns and rows from all four sides of a copy of image x, as long as every pixel in the columns and rows being removed matches the color of the upper-left corner.
Example
| x = {flower(100,100)} | ⇒ | {...} |
| x = {box(100,100,black)} | ⇒ | {...} |
Trim Sides by Top Right Color
Plan to trim all sides of an image with the same color as upper-right corner.
Description
This plan removes columns and rows from all four sides of a copy of image x, as long as every pixel in the columns and rows being removed matches the color of the upper-right corner.
Example
| x = {flower(100,100)} | ⇒ | {...} |
| x = {box(100,100,black)} | ⇒ | {...} |
Trim Sides by Bottom Left Color
Plan to trim all sides of an image with the same color as lower-left corner.
Description
This plan removes columns and rows from all four sides of a copy of image x, as long as every pixel in the columns and rows being removed matches the color of the lower-left corner.
Example
| x = {flower(100,100)} | ⇒ | {...} |
| x = {box(100,100,black)} | ⇒ | {...} |
Trim Sides by Bottom Right Color
Plan to trim all sides of an image with the same color as lower-right corner.
Description
This plan removes columns and rows from all four sides of a copy of image x, as long as every pixel in the columns and rows being removed matches the color of the lower-right corner.
Example
| x = {flower(100,100)} | ⇒ | {...} |
| x = {box(100,100,black)} | ⇒ | {...} |
Rearrange Multiple Images
These plans produce an image by rearranging multiple images.
Conditional Copy
Plan to conditionally copy an image.
Description
This plan copies the image x if image z is valid and not empty; otherwise, it copies the image y. Note that refresh requests are not propagated to the parameters x, y, and z.
Example
| x = {box(10,10,black)}; | y = {box(8,8,red)}; | z = {box(5,5,green)} | ⇒ | {...} |
| x = {box(10,10,black)}; | y = {box(8,8,red)}; | z = {} | ⇒ | {...} |
Stitch in Column
Plan to stitch images in a column (vertically).
Description
This plan arranges copies of images x0, x1, etc. one below the other in a column (vertically), and fills any gaps resulting from different image widths with the specified color.
Example
| color = {160,192,116,255}; | x0 = {line(10,20,black)}; | x1 = {line(10,-20,black)} | ⇒ | {...} |
Stitch in Row
Plan to stitch images in a row (horizontally).
Description
This plan arranges copies of images x0, x1, etc. side by side in a row (horizontally), and fills any gaps resulting from different image heights with the specified color.
Example
| color = {160,192,116,255}; | x0 = {line(10,20,black)}; | x1 = {line(10,-20,black)} | ⇒ | {...} |
Stitch in Collage
Plan to stitch images in a collage.
Description
This plan arranges copies of images x0, x1, etc. into a collage and fills the gaps with the specified color. The image x0 is copied into the position at row i[0] and column j[0] of the collage, the image x1 is copied into the position at row i[1] and column j[1], and so on.
Example
| color = {160,192,116,255}; | i = {0,1,1}; | j = {0,0,1}; | x0 = {line(10,20,black)}; | x1 = {line(10,-20,black)}; | x2 = {flower(100,100)} | ⇒ | {...} |
Modify an Image
These plans produce an image by modifying another image.
Set Pixels
Plan to paint pixels at indices.
Description
This plan paints, in a copy of image x, the pixels at coordinates (x₀, y₀) with color. The pixel at coordinates (x₀[k], y₀[k]) is painted with color[k] for each k. The last color is used when k is out of bounds.
Example
| x = {box(10,10,black)}; | x₀ = {1,2,3}; | y₀ = {0,1,2}; | color = {160,192,116,255} | ⇒ | {...} |
Set Columns From Left
Plan to paint columns at indices counted from left.
Description
This plan paints, in a copy of image x, all the pixels in columns x₀ (counted from the left) with color. The pixels in column x₀[k], counted from the left, are painted with color[k] for each k. The last color is used when k is out of bounds.
Example
| x = {line(10,20,black)}; | x₀ = {0,2,3}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,black)}; | x₀ = {8,3,5}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Set Columns From Right
Plan to paint columns at indices counted from right.
Description
This plan paints, in a copy of image x, all the pixels in columns x₀ (counted from the right) with color. The pixels in column x₀[k], counted from the right, are painted with color[k] for each k. The last color is used when k is out of bounds.
Example
| x = {line(10,20,black)}; | x₀ = {0,2,3}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,black)}; | x₀ = {8,3,5}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Set Rows From Top
Plan to paint rows at indices counted from top.
Description
This plan paints, in a copy of image x, all the pixels in rows y₀ (counted from the top) with color. The pixels in row y₀[k], counted from the top, are painted with color[k] for each k. The last color is used when k is out of bounds.
Example
| x = {line(10,20,black)}; | y₀ = {0,2,3}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,black)}; | y₀ = {8,3,5}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Set Rows From Bottom
Plan to paint rows at indices counted from bottom.
Description
This plan paints, in a copy of image x, all the pixels in rows y₀ (counted from the bottom) with color. The pixels in row y₀[k], counted from the bottom, are painted with color[k] for each k. The last color is used when k is out of bounds.
Example
| x = {line(10,20,black)}; | y₀ = {0,2,3}; | color = {160,192,116,255} | ⇒ | {...} |
| x = {line(10,20,black)}; | y₀ = {8,3,5}; | color = {160,192,116,255,255,0,0,255} | ⇒ | {...} |
Set All Pixels - Channels
Plan to set the color channels of all pixels.
Description
This plan sets the color channels of all the pixels in a copy of image x to r for the red channels, g for the green channels, b for the blue channels, and a for the alpha channels. If r, g, b, or a is not specified, the corresponding color channels are not modified. Color channel values are limited to the range of 0 to 255.
Example
| x = {flower(20,20)}; | r = {0}; | g = {50}; | b = {}; | a = {} | ⇒ | {...} |
| x = {flower(20,20)}; | r = {}; | g = {}; | b = {}; | a = {255} | ⇒ | {...} |
Set Along Columns - Channels
Plan to assign four arrays to the color channels of pixels column by column.
Description
This plan assigns the values in the arrays r, g, b, and a to the red, green, blue, and alpha channels, respectively, of the pixels in a copy of image x along the columns. r[0] is assigned to the red channel of the first pixel, g[0] to the green channel of the first pixel, b[0] to the blue channel of the first pixel, and a[0] to the alpha channel of the first pixel. r[1] is assigned to the red channel of the second pixel, and so on. Color channel values are limited to the range of 0 to 255. Once all values in array r, g, b, or a have been assigned, the remaining red, green, blue, or alpha channels are not modified, respectively.
Example
| x = {flower(20,20)}; | r = {0,255,0,255}; | g = {255,0,255,0}; | b = {}; | a = {255,255,255,255} | ⇒ | {...} |
Set Along Rows - Channels
Plan to assign four arrays to the color channels of pixels row by row.
Description
This plan assigns the values in the arrays r, g, b, and a to the red, green, blue, and alpha channels, respectively, of the pixels in a copy of image x along the rows. r[0] is assigned to the red channel of the first pixel, g[0] to the green channel of the first pixel, b[0] to the blue channel of the first pixel, and a[0] to the alpha channel of the first pixel. r[1] is assigned to the red channel of the second pixel, and so on. Color channel values are limited to the range of 0 to 255. Once all values in array r, g, b, or a have been assigned, the remaining red, green, blue, or alpha channels are not modified, respectively.
Example
| x = {flower(20,20)}; | r = {0,255,0,255}; | g = {255,0,255,0}; | b = {}; | a = {255,255,255,255} | ⇒ | {...} |
Set Along Columns - RGBA
Plan to assign an array to the colors of pixels column by column.
Description
This plan assigns the values in the array c to the RGBA colors of pixels in a copy of image x along the columns. c[0], c[1], c[2], and c[3] are assigned to the red, green, blue, and alpha channels of the first pixel, respectively; c[4], c[5], c[6], and c[7] are assigned to the channels of the second pixel, and so on. Color channel values are limited to the range of 0 to 255. Once all values in array c have been assigned, the colors of the remaining pixels are not modified.
Example
| x = {flower(20,20)}; | c = {0,255,0,255,255,0,0,255,0,255,0,255,255,0,0,255} | ⇒ | {...} |
Set Along Rows - RGBA
Plan to assign an array to the colors of pixels row by row.
Description
This plan assigns the values in the array c to the RGBA colors of pixels in a copy of image x along the rows. c[0], c[1], c[2], and c[3] are assigned to the red, green, blue, and alpha channels of the first pixel, respectively; c[4], c[5], c[6], and c[7] are assigned to the channels of the second pixel, and so on. Color channel values are limited to the range of 0 to 255. Once all values in array c have been assigned, the colors of the remaining pixels are not modified.
Example
| x = {flower(20,20)}; | c = {0,255,0,255,255,0,0,255,0,255,0,255,255,0,0,255} | ⇒ | {...} |
Replace Pixels - RGBA
Plan to repaint pixels based on color.
Description
This plan repaints, in a copy of image x, any pixel that has the same RGBA color as c1[k] with the RGBA color c2[k] for each k. The last RGBA color in c1 and c2 is used when k is out of bounds.
Example
| x = {line(10,20,black)}; | c1 = {0,0,0,255}; | c2 = {255,0,0,255} | ⇒ | {...} |
| x = {line(10,20,black)}; | c1 = {0,0,0,255,0,0,0,0}; | c2 = {255,0,0,255} | ⇒ | {...} |
Replace Pixels - Channels
Plan to repaint pixels based on color channels.
Description
This plan sets, in a copy of image x, the color channels of any pixels that satisfy all of the following conditions: r1≤r≤r2 (for the red channel), g1≤g≤g2 (for the green channel), b1≤b≤b2 (for the blue channel), and a1≤a≤a2 (for the alpha channel). Those pixels are assigned new color channel values: r for red, g for green, b for blue, and a for alpha. When a new color channel value is not specified, the original value is not modified. Color channel values are limited to the range of 0 to 255.
Example
| x = {flower(100,100)}; | r1 = {0}; | r2 = {255}; | g1 = {0}; | g2 = {255}; | b1 = {0}; | b2 = {255}; | a1 = {0}; | a2 = {254}; | r = {}; | b = {250}; | g = {}; | a = {255} | ⇒ | {...} |
Modifying Expressions
Plan to compute color channels with expressions.
Description
This plan sets the pixels in a w×h image by evaluating the expressions r(r, g, b, a, x, y) for the red channel, g(r, g, b, a, x, y) for the green channel, b(r, g, b, a, x, y) for the blue channel, and a(r, g, b, a, x, y) for the alpha channel. Expressions r, g, b, and a are functions of the pixel color channels (r, g, b, and a) and pixel coordinates (x and y). Color channel values are limited to the range of 0 to 255. If the parameters w or h are not specified, they are set to the number of columns and rows, respectively, in the image x.
The expression parser supports the following:
- Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^), and modulus (%).
- Basic operations: abs, ceil, floor, trunc, and round.
- Error and gamma functions: erf, erfc, and gamma.
- Exponentiation functions: exp, pow, and sqrt.
- Combinatorial functions: fac, ncr, and npr.
- Logarithmic functions: exp, ln (natural logarithm), log (base-10 logarithm), and log10.
- Trigonometric functions: sin, cos, tan, asin, acos, atan, and atan2.
- Hyperbolic functions: sinh, cosh, tanh, asinh, acosh, and atanh.
- Constants: pi and e.
Example
| x = {flower(100,100)}; | r = {r+50*cos((x^2+y^2)/100)}; | g = {g+50*cos((x^2+y^2)/100)}; | b = {b+50*cos((x^2+y^2)/100)}; | a = {a}; | w = {}; | h = {} | ⇒ | {...} |
| x = {flower(100,100)}; | r = {(g+b)/2}; | g = {(r+b)/2}; | b = {(r+g)/2}; | a = {a}; | w = {}; | h = {} | ⇒ | {...} |
| x = {}; | r = {50*cos((x^2+y^2)/100)}; | g = {50*cos((x^2+y^2)/100)}; | b = {50*cos((x^2+y^2)/100)}; | a = {255}; | w = {50}; | h = {50} | ⇒ | {...} |
Red Channel
Plan to copy the red channels of pixels.
Description
This plan copies the red channel of each pixel in the image x to produce the output image. The green and blue channels of the pixels are set to zero, while the alpha channels are copied without modification.
Example
| x = {flower(100,100)} | ⇒ | {...} |
Green Channel
Plan to copy the green channels of pixels.
Description
This plan copies the green channel of each pixel in the image x to produce the output image. The red and blue channels of the pixels are set to zero, while the alpha channels are copied without modification.
Example
| x = {flower(100,100)} | ⇒ | {...} |
Blue Channel
Plan to copy the blue channels of pixels.
Description
This plan copies the blue channel of each pixel in the image x to produce the output image. The red and green channels of the pixels are set to zero, while the alpha channels are copied without modification.
Example
| x = {flower(100,100)} | ⇒ | {...} |
Alpha Channel
Plan to copy the alpha channels of pixels.
Description
This plan copies the alpha channel of each pixel in the image x into the red, green, and blue channels to produce the output image. The output is a grayscale image. The alpha channels of the pixels are copied without modification.
Example
| x = {flower(100,100)} | ⇒ | {...} |
Limit Channels
Plan to limit color channels.
Description
This plan limits the color channels of each pixel in the image x to produce the output image. The red channel values are limited to between r1 and r2 by replacing red channel values less than r1 with r1 and values greater than r2 with r2. Similarly, the green channel values are limited to between g1 and g2, the blue channel values are limited to between b1 and b2, and the alpha channel values are limited to between a1 and a2.
Example
| x = {flower(100,100)}; | r1 = {100}; | r2 = {200}; | g1 = {0}; | g2 = {255}; | b1 = {0}; | b2 = {255}; | a1 = {0}; | a2 = {150} | ⇒ | {...} |
Shift and Scale Channels
Plan to shift and scale color channels.
Description
This plan shifts and scales the color channels of pixels in the image x to produce the output image. For a pixel with color channels r, g, b, and a, the red channel is set to r×(r+δr), the green channel is set to g×(g+δg), the blue channel is set to b×(b+δb), and the alpha channel is set to a×(a+δa). Color channel values are limited to the range of 0 to 255.
Example
| x = {flower(100,100)}; | δr = {0}; | r = {1.2}; | δg = {0}; | g = {1}; | δb = {0}; | b = {1}; | δa = {-50}; | a = {1} | ⇒ | {...} |
Scale Channels Toward Limits - Linearly
Plan to scale color channels linearly toward limits.
Description
This plan scales the color channels of pixels in the image x to produce the output image. The scaling is linear toward the limits (0 and 255) by factor r for the red channel, g for the green channel, b for the blue channel, and a for the alpha channel. A factor of 0 preserves a color channel, +1 saturates it at 255, and -1 saturates it at 0.
Example
| x = {flower(100,100)}; | r = {1}; | g = {0}; | b = {0}; | a = {0} | ⇒ | {...} |
Scale Channels Toward Limits - Logarithmically
Plan to scale color channels logarithmically toward limits.
Description
This plan scales the color channels of pixels in the image x to produce the output image. The scaling is logarithmic toward the limits (0 and 255) by factor r for the red channel, g for the green channel, b for the blue channel, and a for the alpha channel. A factor of 0 preserves a color channel, +inf saturates it at 255, and -inf saturates it at 0.
Example
| x = {flower(100,100)}; | r = {1}; | g = {0}; | b = {0}; | a = {0} | ⇒ | {...} |
Translate
Plan to translate an image.
Description
This plan translates the image x horizontally by δx pixels and vertically by δy pixels to produce the output image.
Example
| x = {flower(100,90)}; | δx = {10}; | δy = {-20} | ⇒ | {...} |
Scale
Plan to scale an image.
Description
This plan scales the image x by the specified scale factors: sx along the horizontal direction and sy along the vertical direction, to produce the output image.
Example
| x = {flower(100,90)}; | sx = {1.2}; | sy = {0.7} | ⇒ | {...} |
Rotate
Plan to rotate an image.
Description
This plan rotates the image x about its center by the specified angle (in degrees) to produce the output image. A positive angle is measured counterclockwise.
Example
| x = {flower(100,90)}; | angle = {-45} | ⇒ | {...} |
Shear
Plan to shear an image.
Description
This plan shears the image x about its center by the specified shear factors: sx along the horizontal direction and sy along the vertical direction, to produce the output image.
Example
| x = {flower(100,90)}; | sx = {0.5}; | sy = {0.2} | ⇒ | {...} |
Transform
Plan to transform an image.
Description
This plan transforms the image x about its center using the specified transformation array t = {t11,t12,t13,t21,t22,t23,t31,t32,t33} to produce the output image. t31 and t32 specify horizontal and vertical translations, t11 and t22 specify horizontal and vertical scaling, and t21 and t12 specify horizontal and vertical shearing. Finally, t13 and t23 specify horizontal and vertical projections, while t33 is an additional projection factor.
Example
| x = {flower(100,90)}; | t = {1,0.2,0,0.5,1,0,0,0,1} | ⇒ | {...} |
Mirror Horizontally and Rotate
Plan to rotate a horizontally-mirrored image.
Description
This plan mirrors the image x horizontally (about the vertical axis), and subsequently rotates it by the specified angle (in degrees) to produce the output image. A positive angle is measured counterclockwise.
Example
| x = {flower(100,90)}; | angle = {-45} | ⇒ | {...} |
Mirror Vertically and Rotate
Plan to rotate a vertically-mirrored image.
Description
This plan mirrors the image x vertically (about the horizontal axis), and subsequently rotates it by the specified angle (in degrees) to produce the output image. A positive angle is measured counterclockwise.
Example
| x = {flower(100,90)}; | angle = {-45} | ⇒ | {...} |
Resize - Fixed Aspect Ratio
Plan to resize an image with fixed aspect ratio.
Description
This plan stretches or shrinks the image x to w×h to produce the output image. When a dimension is not specified, the aspect ratio is preserved.
Example
| x = {flower(100,90)}; | w = {200}; | h = {} | ⇒ | {...} |
| x = {flower(100,90)}; | w = {}; | h = {200} | ⇒ | {...} |
Resize - Stretch
Plan to resize and stretch an image.
Description
This plan stretches or shrinks the image x to w×h to produce the output image. When a dimension is not specified, it is preserved.
Example
| x = {flower(100,90)}; | w = {200}; | h = {} | ⇒ | {...} |
| x = {flower(100,90)}; | w = {}; | h = {200} | ⇒ | {...} |
Blur - Geometric Mean Filter
Plan to blur an image with geometric mean filter.
Description
This plan blurs a copy of image x using a w×h geometric mean filter mask. w and h are rounded to the nearest positive odd numbers.
Example
| x = {flower(100,90)}; | w = {3}; | h = {3} | ⇒ | {...} |
| x = {flower(100,90)}; | w = {11}; | h = {1} | ⇒ | {...} |
Blur - Box Filter
Plan to blur an image with box filter.
Description
This plan blurs a copy of image x using a w×h normalized box filter. w and h are rounded to the nearest positive odd numbers.
Example
| x = {flower(100,90)}; | w = {3}; | h = {3} | ⇒ | {...} |
| x = {flower(100,90)}; | w = {11}; | h = {1} | ⇒ | {...} |
Blur - Gaussian Filter
Plan to blur an image with Gaussian filter.
Description
This plan blurs a copy of image x using a w×h Gaussian kernel (aperture). w and h are rounded to the nearest positive odd numbers.
Example
| x = {flower(100,90)}; | w = {3}; | h = {3} | ⇒ | {...} |
| x = {flower(100,90)}; | w = {11}; | h = {1} | ⇒ | {...} |
Convolution
Plan to convolve an image with linear kernel.
Description
This plan applies a general linear filter to a copy of image x. The convolution filter is specified by the kernel matrix. The center of the kernel is positioned at the point being filtered.
Example
| x = {flower(100,90)}; | k = {1/9,1/9,1/9;1/9,1/9,1/9;1/9,1/9,1/9} | ⇒ | {...} |
| x = {flower(100,90)}; | k = {0.05,0.1,0.05;0.05,0.5,0.05;0.05,0.1,0.05} | ⇒ | {...} |
OpenAI - Image Edit
Plan to edit an image with OpenAI API.
Description
This plan edits a masked area in the image x, as defined by the transparent areas in the image mask, following a prompt. It uses the OpenAI API, with requests authenticated using an api key. The specified mask image is trimmed or extended by adding transparent rows and columns to match the size of image x.
Notes:
- To acquire an api key, go to https://platform.openai.com.
- To learn more about the API parameters, visit https://platform.openai.com/docs/api-reference/images/createEdit.
- This plan requests data from OpenAI's servers by sharing the plan parameters. The Terms of Use for OpenAI are available at https://openai.com/policies/terms-of-use.
- You may need to increase the network timeout (Preferences > Network Timeout) to allow enough time for the API response to arrive.
- A corresponding plan to generate the complete API response is available under Text Plans/Get/3rd-Party Importers - Raw Response.
Example
| x = {flower(512,512)}; | mask = {circle(200,white)}; | prompt = {A flower with fiery corners.}; | api key = {...} | ⇒ | {...} |
OpenAI - Image Variation
Plan to generate an image variation with OpenAI API.
Description
This plan generates a variation of the image x using the OpenAI API. Requests are authenticated with an api key.
Notes:
- To acquire an api key, go to https://platform.openai.com.
- To learn more about the API parameters, visit https://platform.openai.com/docs/api-reference/images/createVariation.
- This plan requests data from OpenAI's servers by sharing the plan parameters. The Terms of Use for OpenAI are available at https://openai.com/policies/terms-of-use.
- You may need to increase the network timeout (Preferences > Network Timeout) to allow enough time for the API response to arrive.
- A corresponding plan to generate the complete API response is available under Text Plans/Get/3rd-Party Importers - Raw Response.
Example
| x = {flower(512,512)}; | api key = {...} | ⇒ | {...} |
Modify Multiple Images
These plans produce an image by modifying multiple images.
Expressions Across Images
Plan to compute color channels with expressions across images.
Description
This plan evaluates the expressions r(x,y,r0,g0,b0,a0,r1,g1,b1,a1,...), g(x,y,r0,g0,b0,a0,r1,g1,b1,a1,...), b(x,y,r0,g0,b0,a0,r1,g1,b1,a1,...), a(x,y,r0,g0,b0,a0,r1,g1,b1,a1,...) for each pixel at coordinates (x, y), to produce the red, green, blue, and alpha channels, respectively, of the pixels in the output image. In these expressions, x and y are pixel coordinates, both starting from 0. r0, g0, b0, and a0 are, respectively, the red, green, blue, and alpha channel values of the pixel at coordinates (x, y) in the image x0. Similarly, r1, g1, b1, and a1 are the color channel values for the pixel at coordinates (x, y) in the image x1, and so on. This plan can process up to 10 images, using expressions of the color channels at the same position across images. The output image is as large as the largest xk image, and zero is used for out-of-range color channels.
The expression parser supports the following:
- Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^), and modulus (%).
- Basic operations: abs, ceil, floor, trunc, and round.
- Error and gamma functions: erf, erfc, and gamma.
- Exponentiation functions: exp, pow, and sqrt.
- Combinatorial functions: fac, ncr, and npr.
- Logarithmic functions: exp, ln (natural logarithm), log (base-10 logarithm), and log10.
- Trigonometric functions: sin, cos, tan, asin, acos, atan, and atan2.
- Hyperbolic functions: sinh, cosh, tanh, asinh, acosh, and atanh.
- Constants: pi and e.
Example
| r = {0.5*(r0+r1)}; | g = {0.5*(g0+g1)}; | b = {0.5*(b0+b1)}; | a = {a0+a1)}; | x0 = {flower(100,100)}; | x1 = {flower(70,50)} | ⇒ | {...} |
Alpha Blend
Plan to alpha blend images.
Description
This plan alpha-blends the images x0, x1, and so on over one another to produce the output image.
Example
| x0 = {flower(100,90)}; | x1 = {box(30,40,green)}; | x2 = {line(90,-50,yellow)} | ⇒ | {...} | |
| x0 = {box(100,100,transparent)}; | x1 = {box(20,20,white)}; | x2 = {circle(100,cyan)}; | x3 = {flower(100,100)} | ⇒ | {...} |
Compositing - Average of Channels
Plan to combine images by averaging color channels.
Description
This plan combines the images x0, x1, and so on by averaging the RGB color channels and maximizing the alpha channel at each position across images to produce the output image.
Example
| x0 = {flower(100,90)}; | x1 = {box(30,40,green)}; | x2 = {line(90,-50,yellow)} | ⇒ | {...} | |
| x0 = {box(100,100,transparent)}; | x1 = {box(20,20,white)}; | x2 = {circle(100,cyan)}; | x3 = {flower(100,100)} | ⇒ | {...} |
Compositing - Weighted Average of Channels
Plan to combine images by averaging weighted color channels.
Description
This plan combines the images x0, x1, and so on by averaging the weighted RGB color channels and maximizing the alpha channel at each position across images to produce the output image. The weights for the red, green, and blue channels are given in the arrays r, g, and b, so that the red channel in x0 is weighted by r[0], and so on.
Example
| r = {2,1,1}; | g = {2,1,1}; | b = {2,1,1}; | x0 = {flower(100,90)}; | x1 = {box(30,40,green)}; | x2 = {line(90,-50,yellow)} | ⇒ | {...} | |
| r = {1,1,1,5}; | g = {1,1,1,5}; | b = {1,1,1,1}; | x0 = {box(100,100,transparent)}; | x1 = {box(20,20,white)}; | x2 = {circle(100,cyan)}; | x3 = {flower(100,100)} | ⇒ | {...} |
Highlight an Image
These plans produce an image by extracting information from another image.
Column Count
Plan to count image columns.
Description
This plan counts the number of columns, or the width w, of the image x.
Example
| x = {line(100,50,blue)} | ⇒ | {100} |
Row Count
Plan to count image rows.
Description
This plan counts the number of rows, or the height h, of the image x.
Example
| x = {line(100,50,blue)} | ⇒ | {50} |
Extract Along Columns - Expression
Plan to copy after applying an expression column by column.
Description
This plan copies the evaluation result of the expression f(r,g,b,a,x,y) when applied along the columns. Here, f is a function of the pixel color channels (r, g, b, and a) and pixel coordinates (x and y). Effectively, this plan converts the image into an array.
The expression parser supports the following:
- Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^), and modulus (%).
- Basic operations: abs, ceil, floor, trunc, and round.
- Error and gamma functions: erf, erfc, and gamma.
- Exponentiation functions: exp, pow, and sqrt.
- Combinatorial functions: fac, ncr, and npr.
- Logarithmic functions: exp, ln (natural logarithm), log (base-10 logarithm), and log10.
- Trigonometric functions: sin, cos, tan, asin, acos, atan, and atan2.
- Hyperbolic functions: sinh, cosh, tanh, asinh, acosh, and atanh.
- Constants: pi and e.
Example
| x = {box(2,2,blue)}; | f = {r+g+10*b+x-y} | ⇒ | {2550,2549,2551,2550} |
Extract Along Rows - Expression
Plan to copy after applying an expression row by row.
Description
This plan copies the evaluation result of the expression f(r,g,b,a,x,y) when applied along the rows. Here, f is a function of the pixel color channels (r, g, b, and a) and pixel coordinates (x and y). Effectively, this plan converts the image into an array.
The expression parser supports the following:
- Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^), and modulus (%).
- Basic operations: abs, ceil, floor, trunc, and round.
- Error and gamma functions: erf, erfc, and gamma.
- Exponentiation functions: exp, pow, and sqrt.
- Combinatorial functions: fac, ncr, and npr.
- Logarithmic functions: exp, ln (natural logarithm), log (base-10 logarithm), and log10.
- Trigonometric functions: sin, cos, tan, asin, acos, atan, and atan2.
- Hyperbolic functions: sinh, cosh, tanh, asinh, acosh, and atanh.
- Constants: pi and e.
Example
| x = {box(2,2,blue)}; | f = {r+g+10*b+x-y} | ⇒ | {2550,2551,2549,2550} |
Extract Along Columns - Red Channel
Plan to copy the red channels of pixels column by column.
Description
This plan copies the red channel of each pixel in the image x along the columns, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {240,241,0,240,240,239,239,240,240,0,241,240} |
Extract Along Rows - Red Channel
Plan to copy the red channels of pixels row by row.
Description
This plan copies the red channel of each pixel in the image x along the rows, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {240,240,239,0,241,240,240,241,0,239,240,240} |
Extract Along Columns - Green Channel
Plan to copy the green channels of pixels column by column.
Description
This plan copies the green channel of each pixel in the image x along the columns, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {230,229,0,230,230,231,231,230,230,0,229,230} |
Extract Along Rows - Green Channel
Plan to copy the green channels of pixels row by row.
Description
This plan copies the green channel of each pixel in the image x along the rows, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {230,230,231,0,229,230,230,229,0,231,230,230} |
Extract Along Columns - Blue Channel
Plan to copy the blue channels of pixels column by column.
Description
This plan copies the blue channel of each pixel in the image x along the columns, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {140,140,0,140,140,141,140,140,140,0,140,140} |
Extract Along Rows - Blue Channel
Plan to copy the blue channels of pixels row by row.
Description
This plan copies the blue channel of each pixel in the image x along the rows, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {140,140,140,0,140,140,140,140,0,141,140,140} |
Extract Along Columns - Alpha Channel
Plan to copy the alpha channels of pixels column by column.
Description
This plan copies the alpha channel of each pixel in the image x along the columns, effectively converting the image into an array.
Example
| x = {line(4,3,brown)} | ⇒ | {255,159,0,244,255,96,95,255,244,0,159,255} |
Extract Along Rows - Alpha Channel
Plan to copy the alpha channels of pixels row by row.
Description
This plan copies the alpha channel of each pixel in the image x along the rows, effectively converting the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {255,244,95,0,159,255,255,159,0,96,244,255} |
Extract Along Columns - RGBA
Plan to copy the color channels of pixels column by column.
Description
This plan copies the red, green, blue, and alpha channels of each pixel in the image x, in order, along the columns. The first four values in the output array represent the red, green, blue, and alpha channels of the first pixel; the next four values correspond to the second pixel, and so on. Effectively, this plan converts the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {240,230,140,255,241,229,140,159,0,0,0,0,...} |
Extract Along Rows - RGBA
Plan to copy the color channels of pixels row by row.
Description
This plan copies the red, green, blue, and alpha channels of each pixel in the image x, in order, along the rows. The first four values in the output array represent the red, green, blue, and alpha channels of the first pixel; the next four values correspond to the second pixel, and so on. Effectively, this plan converts the image into an array.
Example
| x = {line(4,3,khaki)} | ⇒ | {240,230,140,255,240,230,140,244,239,231,140,95,...} |
Object Detection
Plan to detect objects with cascade classifier algorithm.
Description
This plan detects objects in the image x using the cascade classifier algorithm. If objects are detected, the bounding rectangles are listed with the coordinates of their opposite corners p and q as {p1,x,p1,y,q1,x,q1,y,p2,x,... }. The location of the classifier file is specified by the file name. For an object to be detected, a valid object rectangle must have at least n candidate neighbors. In each classification pass, the detection window is enlarged by the scale factor.
Example
| x = {...}; | file name = {tests\haarcascade_frontalface_alt.xml}; | n = {3}; | scale = {1.1} | ⇒ | {...} |
Post Images
These plans output images without producing any new data.
Export to Image File
Plan to export an image to an image file.
Description
This plan exports the image x to an image file. This plan automatically detects the image format from the given file name. When applicable, compression is controlled by a quality factor in the range of 0 to 100, or -1, where 100 results in no compression (largest file), 0 results in maximum compression (smallest file), and -1 applies the default settings.
Example
| x = {circle(200,blue)}; | file name = {tests\testimage.jpg}; | quality = {-1} |
Export to BMP File
Plan to export an image to a BMP file.
Description
This plan exports the image x to a Windows Bitmap (BMP) file with the given file name.
Example
| x = {circle(200,red)}; | file name = {tests\testimage.bmp} |
Export to JPG File
Plan to export an image to a JPG file.
Description
This plan exports the image x to a Joint Photographic Experts Group (JPG) file with the given file name. Compression is controlled by a quality factor in the range of 0 to 100, or -1, where 100 results in no compression (largest file), 0 results in maximum compression (smallest file), and -1 applies the default settings.
Example
| x = {circle(200,blue)}; | file name = {tests\testimage.jpg}; | quality = {-1} |
Export to PNG File
Plan to export an image to a PNG file.
Description
This plan exports the image x to a Portable Network Graphics (PNG) file with the given file name. Compression is controlled by a quality factor in the range of 0 to 100, or -1, where 100 results in no compression (largest file), 0 results in maximum compression (smallest file), and -1 applies the default settings.
Example
| x = {circle(200,yellow)}; | file name = {tests\testimage.png}; | quality = {-1} |
Export to PPM File
Plan to export an image to a PPM file.
Description
This plan exports the image x to a Portable Pixel Map (PPM) file with the given file name.
Example
| x = {circle(200,gray)}; | file name = {tests\testimage.ppm} |
Export to XBM File
Plan to export an image to an XBM file.
Description
This plan exports the image x to an X11 Bitmap (XBM) file with the given file name.
Example
| x = {circle(200,lightblue)}; | file name = {tests\testimage.xbm} |
Export to XPM File
Plan to export an image to an XPM file.
Description
This plan exports the image x to an X11 Pixel Map (XPM) file with the given file name.
Example
| x = {circle(200,palegreen)}; | file name = {tests\testimage.xpm} |
Export to Video File
Plan to export images to a video file.
Description
This plan exports the images x0, x1, etc. to a video file with the given file name. If the append parameter is not empty, the images are appended to the end of the file. cccc, or FourCC, is the 4-character code of the codec used to compress the frames. For example, PIM1 requests the MPEG-1 codec, MJPG requests the Motion JPEG codec, etc. The parameter api is the OpenCV VideoCapture API backend identifier. If api is set to 0, the available backend is auto-detected. Finally, fps specifies the frame rate of the video.
Example
| file name = {tests\test.avi}; | cccc = {}; | api = {0}; | fps = {2}; | x0 = {circle(200,greenyellow)}; | x1 = {circle(200,lightgreen)}; | x2 = {circle(200,yellowgreen)}; | x3 = {circle(200,green)} |
TextRequest - Image Message
Plan to send images over the cellular network with TextRequest API.
Description
This plan sends the images x0, x1, etc. together with an optional text message, from a source phone number (assigned by TextRequest) to a destination mobile phone number using the TextRequest API. Requests are authenticated with an api key.
Notes:
- To acquire an api key and a source phone number, go to https://www.textrequest.com/pricing.
- To learn more about the API parameters, visit https://www.textrequest.com/api/v3#/.
- This plan requests data from TextRequest's servers by sharing the plan parameters. The Terms of Service for TextRequest are available at https://www.textrequest.com/terms-of-service.
- By calling the TextRequest API, users agree to follow the Acceptable Use Policy provided by TextRequest at https://www.textrequest.com/acceptable-use.
- You may need to increase the network timeout (Preferences > Network Timeout) to allow enough time for the API response to arrive.
- A corresponding plan to generate the complete API response is available under Text Plans/Get/3rd-Party Importers - Raw Response.
Example
| source = {...}; | destination = {...}; | api key = {...}; | message = {}; | x0 = {flower(100,100)}; | x1 = {circle(200,lightgreen)} |