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)
🧭 precise: support for super precise calculations (by using preciso)
⭐ type-safe: supports TypeScript
bash
npm install calc-image-stats
basic usage
import calcImageStats from "calc-image-stats";
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,
];
const stats = calcImageStats(data, { height: 10, width: 10 });
stats will be the following object:
{
depth: 4,
height: 10,
width: 10,
bands: [
{
count: 100,
valid: 100,
invalid: 0,
median: 87,
min: 9,
max: 220,
sum: 10489,
range: 211,
mean: 104.89,
std: 53.908792418305936,
modes: [51, 69, 87, 190],
mode: 99.25
},
{ ... },
{ ... },
{
count: 100,
valid: 100,
invalid: 0,
median: 255,
min: 255,
max: 255,
sum: 25500,
range: 0,
mean: 255,
std: 0,
modes: [255],
mode: 255
}
]
};
advanced usage
const stats = calcImageStats(data, {
height: 123456,
precise: true,
stats: ["variance"],
width: 123456
});
{
depth: 1,
height: 123456,
width: 123456,
bands: [
{
variance: "1321.41725347154236125321387514273412736"
}
]
}