sobel
Sobel Filter algorithm in JavaScript.
Sobel Filter is an algorithm often used for edge detection.
Demo
https://lab.miguelmota.com/sobel
Install
npm install sobel
Getting started
var canvas = document;var context = canvas; var image = ;imagesrc = 'images/valve.png';imageonload = drawImage; { var width = imagewidth; var height = imageheight; canvaswidth = width; canvasheight = height; context; var imageData = context; // Sobel constructor returns an Uint8ClampedArray with sobel data var sobelData = ; // [sobelData].toImageData() returns a new ImageData object var sobelImageData = sobelData; context;}
Same example as above but using a Web Worker:
var canvas = document;var context = canvas; var image = ;imagesrc = 'images/valve.png';imageonload = drawImage; { var width = imagewidth; var height = imageheight; canvaswidth = width; canvasheight = height; context; var imageData = context; var ww = '/webWorker.js'; ww; ww { var sobelData = eventdata; // Sobel.toImageData() returns a new ImageData object var sobelImageData = Sobel; contextSobel; };}
In webWorker.js
:
; self { // Sobel constructor returns an Uint8ClampedArray with sobel data var sobelData = ; self;};
Check out the full example in the example folder.