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