Canny Edge Detection

Detects edges using the Canny edge detection algorithm.

Parameters

texture Texture: The input texture to be filtered. Default: The entire canvas
texOffset Vec2: The offset used for sampling neighboring pixels. Default: (1.0 / width, 1.0 / height)
thresholdLow Float: The lower threshold for edge detection. Pixels with intensity gradients below this threshold will be suppressed. Default: 0.1
thresholdHigh Float: The higher threshold for edge detection. Pixels with intensity gradients above this threshold will be considered strong edges. Default: 0.3

Example

import fip.*;

PShader cannyEdgeDetection;
PImage ireland;

void setup() {
  size(1000, 1000, P3D);

  cannyEdgeDetection = loadShader(FIP.cannyEdgeDetection);

  ireland = loadImage("ireland.jpg");

  cannyEdgeDetection.set("thresholdLow", 0.1);
  cannyEdgeDetection.set("thresholdHigh", 0.3);
}

void draw() {
  image(ireland, 0, 0, width, height);

  filter(cannyEdgeDetection);
}