Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calc-image-stats

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calc-image-stats

Calculate Band Statistics for an Image

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-8.74%
Maintainers
1
Weekly downloads
 
Created
Source

calc-image-stats

Calculate Band Statistics for an Image

features

🦺 memory-safe: uses iterators to avoid copying pixel value arrays
🚀 fast: uses calc-stats, which avoids intermediary calculations
♦️ dynamic: works on numerical image data in any layout (by using xdim)

bash

npm install calc-image-stats

usage

import calcImageStats from "calc-image-stats";

// array of RGBA values of 10x10 image
const data = [
   52,  70,  42, 255, 56,  72, 53, 255,  45,  60,  45, 255,
   37,  54,  30, 255, 62,  85, 48, 255,  70,  88,  53, 255,
   // ... 376 more items
];

const stats = calcImageStats(data, { height: 10, width: 10 });

stats will be the following object:

{
  depth: 4, // number of bands
  height: 10,
  width: 10,
  bands: [
    {
      // red band
      median: 87,
      min: 9,
      max: 220,
      sum: 10489,
      range: 211,
      mean: 104.89,
      modes: [51, 69, 87, 190],
      mode: 99.25
    },
    { ... }, // green band
    { ... }, // blue band
    {
      // alpha band
      median: 255,
      min: 255,
      max: 255,
      sum: 25500,
      range: 0,
      mean: 255,
      modes: [255],
      mode: 255
    }
  ]
};

Keywords

FAQs

Package last updated on 16 Nov 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc