JSPM

tf-gaussian-blur

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q37614F
  • License MIT

A small gaussian blur library for tensorflow.js (tf.js)

Package Exports

  • tf-gaussian-blur

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tf-gaussian-blur) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Gaussian blur for tf.js

This is a small, very fast library to execute image filters using Web.GL on any runtime supported by Tensorflow.js.

Demo

Install

npm install --save tf-gaussian-blur

Example

Create a kernel tensor.

This is a symetric (NxNx3x1) tensor that is convolved across an image tensor to generate a blur effect.

size determines the dimension of the kernel. The larger size the more surrounding pixels are included in the filter. size must be odd. Computation time increases exponentially as size increases.

sigma is optional and sets the standard deviation of the gaussian distribution. A higher sigma gives further pixels higher weight in the output.

const gaussianBlur = require("tf-gaussian-blur");

// get a 5x5 symetric gaussian filter
const size = 5
const sigma = 2
const kernel = blur.getGaussianKernel(size, sigma)

Apply the kernel to an image

var image = tf.browser.fromPixels(document.getElementById("img"))

var blurredImage = blur.blur(image, kernel)

tf.browser.toPixels(image,  document.getElementById("canvas"))