Automate

Automate

Make your phone or tablet smarter with automation

Get it on Google Play

Image sample color

An action block that samples the color of pixels in an image.

The fiber will pause until the image operation has finished.

This block will sample from the bitmap held in memory by the fiber, as loaded by a prior Image load block.

If the sample size if larger than 1 then the resulting color components and alpha are averages of the pixels in sampled area.

The number and range of the resulting color components depends on the color model, derived of the source image, its format and encoding. Commonly used color models are Grayscale, RGB, YCbCr, CMYK and YCCK. Never assume an image is in a particular color model, always check the resulting color model. Use the colorRecode function to convert between color models, e.g. from sampled to RGB: colorRecode(sampledComponents, sampledColorModel++" RGB")

Input arguments

  • Sample X — horizontal center of sample area, in pixels.
  • Sample Y — vertical center of sample area, in pixels.
  • Sample size — square size of sample area, in pixels, must be odd, default is 1.

Output variables

  • Color model — variable to assign the name of the color model of the sample, describing the resulting color components.
  • Sampled color components — variable to assign an arrays with the average of each color components, normalized.
  • Sampled alpha — variable to assign the average alpha factor [0,1] of sampled pixels.
Note! This documentation is also accessible within the app from Help & feedback menu.