內容感知圖像裁剪:smartcrop.js

jopen 9年前發布 | 15K 次閱讀 圖形/圖像處理 smartcrop.js

Smartcrop.js實現了一種算法來進行更好的進行截圖。

Example
Image: https://www.flickr.com/photos/endogamia/5682480447/ by N. Feans

示例

算法概覽

Smartcrop.js works using fairly dumb image processing. In short:

  1. Find edges using laplace
  2. Find regions with a color like skin
  3. Find regions high in saturation
  4. Generate a set of candidate crops using a sliding window
  5. Rank them using a importance function to focus the detail in the center and avoid it in the edges.
  6. Output the candidate crop with the highest rank

Simple Example

SmartCrop.crop(image, {width: 100, height: 100}, function(result){console.log(result);});
// {topCrop: {x: 300, y: 200, height: 200, width: 200}}

Download/ Installation

npm install smartcroporbower install smartcropor just download smartcrop.js from the git repo.

CLI / Node.js

The smartcrop-cli offers command line interface to smartcrop.js. It is based on node.js and node-canvas. You can also view it as an example on how to use smartcrop.js from a node.js app.

Module Formats

Supported:

  • common js
  • amd
  • global export / window

項目主頁:http://www.baiduhome.net/lib/view/home/1444827996232

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!