Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Processing library that lets you pull out RGB, brightness, hue, and saturation channels from a PImage
Java Shell
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
data
distribution
examples
lib
resources
src/channels
web
.gitignore
license.txt
readme.md

readme.md

Channels

Download Channels

Processing Channels library demo

Channels is a Processing library that lets you extract the red, green, blue, hue, saturation, or brightness channels from a PImage. It works similarly to Processing's built-in red(), green(), blue(), brightness(), hue(), and saturation() functions, but instead of applying to individual pixels, Channels' equivalent functions apply to the entire image.

Extracting individual channels can be useful for visualizing or analyzing images. Channels can be used to modify an image in place for display or to extract an array of ints representing the pixels for the relevant channel.

Examples

Here's an example of the first mode: modifying a PImage in place so it displays just one channel of the original image.

PImage myImage;
void setup(){
  size(500,500);
  myImage = loadImage("testImage.png"); // a square image around 500x500 pixels
  Channels.red(myImage);
}

void draw(){
  image(myImage,0,0);
}

Here's an example of the second mode: extracting the pixels of a particular channel for use:

PImage myImage;
int[] myPixels;
void setup(){
  size(500,500);
  myImage = loadImage(testImage.png);
  myPixels = new int[myImage.width * myImage.height];

  myImage.loadPixels();
  myPixels = Channels.red(myImage.pixels);
}

void draw(){
  for(int i = 0; i < myPixels.length; i++){
    // do something with the pixels in the red channel...
  }
}

An example of something useful to do with the pixels of a given channel might be to run the marching squares algorithm on it using the Isolines Processing library.

Something went wrong with that request. Please try again.