You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

seam-carving-js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seam-carving-js

A Javascript implementation of Seam Carving algorithm (content-aware image resizing)

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
6
50%
Maintainers
1
Weekly downloads
 
Created
Source

##Install

npm install 

##Install for contributors

OSX requires

brew install pkg-config cairo libpng jpeg giflib
xcode-select --install # el capitain only

Ubuntu

sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

Everyone

npm install

##Build

gulp build

##Test

npm run test

##Run demo

npm install -g local-web-server
ws # navigate to http://localhost:8000

##Current optimizations

  • When we remove a seam not all pixels are recalculated instead only pixels either side of the seam are enqueued to be recalculated. If the min sum of the affected pixel has not changed we need not enqueue it's children.

##Potential optimizations

  • Iterate arrays in a CPU cache efficient way
  • Keep track of smallest on top row
  • Have three matrices, one for minx, one for vminsum and one for energies so that we can use typed arrays
  • Could convert picture rgba array to Uint32Array rgb number array to save space
  • Do logical deletes on the energy matrix. This way the cost of deletion goes way down, with the cost of finding the neighbor when recalculating going up some. Would have to keep picture array as an array of Uint8ClampedArrays.
  • Potentially could add the pixels which we need to recalculate the energy for to a queue of nodes and relax there edges to adjacent pixels. If we do not find a smaller vminsum for any pixel on the queue we do not need to iterate its descendants.
  • There might be a (slightly) better way to remove the seam, with less conversion between coordinates.

FAQs

Package last updated on 30 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts