colorGraph:从图像中提取颜色统计信息的 javscript 模块

  • m5_429219
    了解作者
  • 44.4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 03:04
    上传日期
#颜色图 颜色图是一个节点模块,它采用 HTML 画布并在其上执行各种收集/统计任务。 这可用于创建色觉,或帮助从图像数据创建生成艺术作品。 我将很快包含一个浏览器版本。 #例子 var fs = require ( 'fs' ) , ColorGraph = require ( './index.js' ) , Canvas = require ( 'canvas' ) , Image = Canvas . Image ; var imgRaw = fs . readFileSync ( './lisa.jpg' ) , img = new Image ; img . src = imgRaw ; var canvas = new Canvas ( img . width , img . height ) , ctx = canvas . getContex
colorGraph-master.zip
  • colorGraph-master
  • example.js
    905B
  • dark.jpg
    33.6KB
  • README.md
    1.2KB
  • index.js
    2.8KB
  • lisa.jpg
    8.4KB
  • package.json
    642B
内容介绍
#Color Graph Color Graph is a node module that takes an HTML canvas and performs various collection/statistical tasks on it. This can be used to create color palates, or to help create generative artworks from image data. I will include a browser version soon. #Example ```javascript var fs = require('fs') , ColorGraph = require('./index.js') , Canvas = require('canvas') , Image = Canvas.Image; var imgRaw = fs.readFileSync('./lisa.jpg'), img = new Image; img.src = imgRaw; var canvas = new Canvas(img.width, img.height), ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); var d = ColorGraph({trim: 0}); //Get all colors in a canvas - one color for each pixel var points = d.getPoints(canvas); console.log(points); //Get a list of all colors in a canvas along with their occurrence count d.getGraph(canvas, function(colorGraph){ console.log(colorGraph); }); //Get a list of 5 of the main colors in an image. Uses clustering to work out general color groups then averages them. d.getDominantColors(canvas, function(results){ console.log('RGB:'); console.log(results); }); ``` If you have any issues or requests please make an issue and I'll do my best to include it.
评论