UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 754 B
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import t from"../PixelBlock.js";import{getPixelValueRange as e}from"../rasterFormats/pixelRangeUtils.js";function i(i,s,a){const{pixels:l,width:n,height:r,mask:o,bandMasks:h}=i,p=n*r,m=h?.length?t.combineBandMasks(h):o,f=Math.min(s.length,l.length),c=a.startsWith("f"),d=!c&&a!==i.pixelType,[x,g]=e(a),k=t.createEmptyBand(a,p);for(let t=0;t<r;t++){let e=t*n;for(let t=0;t<n;t++,e++)if(!m||m[e]){let t=0;for(let i=0;i<f;i++)t+=s[i]*l[i][e];c||(t=Math.round(t),d&&(t=t>g?g:t<x?x:t)),k[e]=t}}const u=new t({width:n,height:r,pixels:[k],pixelType:a,mask:m});return u.updateStatistics(),u}export{i as grayscale};