Standard conversion from rgbe to float pixels.  Note: Ward uses
ldexp(col+0.5,exp-(128+8)). However we wanted pixels in the
range [0,1] to map back into the range [0,1].
357079
public static void rgbe2float(float[] rgb, byte[] rgbe, int startRGBEOffset) {
        float f;

        if (rgbe[startRGBEOffset + 3] != 0) {   // nonzero pixel
            f = (float) ldexp(1.0, (rgbe[startRGBEOffset + 3] & 0xFF) - (128 + 8));
            rgb[0] = (rgbe[startRGBEOffset + 0] & 0xFF) * f;
            rgb[1] = (rgbe[startRGBEOffset + 1] & 0xFF) * f;
            rgb[2] = (rgbe[startRGBEOffset + 2] & 0xFF) * f;
        }
        else {
            rgb[0] = 0;
            rgb[1] = 0;
            rgb[2] = 0;
        }
    }
426269
public static int pixelTypeToGL(
    final JCGLPixelFormat p)
  {
    switch (p) {
      case PIXEL_COMPONENT_BYTE:
        return GL11.GL_BYTE;
      case PIXEL_COMPONENT_FLOAT:
        return GL11.GL_FLOAT;
      case PIXEL_COMPONENT_INT:
        return GL11.GL_INT;
      case PIXEL_COMPONENT_SHORT:
        return GL11.GL_SHORT;
      case PIXEL_COMPONENT_UNSIGNED_BYTE:
        return GL11.GL_UNSIGNED_BYTE;
      case PIXEL_COMPONENT_UNSIGNED_INT:
        return GL11.GL_UNSIGNED_INT;
      case PIXEL_COMPONENT_UNSIGNED_SHORT:
        return GL11.GL_UNSIGNED_SHORT;
      case PIXEL_PACKED_UNSIGNED_INT_1010102:
        return GL12.GL_UNSIGNED_INT_10_10_10_2;
      case PIXEL_PACKED_UNSIGNED_SHORT_4444:
        return GLES20.GL_UNSIGNED_SHORT_4_4_4_4;
      case PIXEL_PACKED_UNSIGNED_SHORT_5551:
        return GLES20.GL_UNSIGNED_SHORT_5_5_5_1;
      case PIXEL_PACKED_UNSIGNED_SHORT_565:
        return GLES20.GL_UNSIGNED_SHORT_5_6_5;
      case PIXEL_COMPONENT_HALF_FLOAT:
        return GL30.GL_HALF_FLOAT;
      case PIXEL_PACKED_UNSIGNED_INT_24_8:
        return GL30.GL_UNSIGNED_INT_24_8;
    }

    throw new UnreachableCodeException();
  }
37829
function getPixelValues (pixelData) {
  let minPixelValue = Number.MAX_VALUE;
  let maxPixelValue = Number.MIN_VALUE;
  const len = pixelData.length;
  let pixel;

  for (let i = 0; i < len; i++) {
    pixel = pixelData[i];
    minPixelValue = minPixelValue < pixel ? minPixelValue : pixel;
    maxPixelValue = maxPixelValue > pixel ? maxPixelValue : pixel;
  }

  return {
    minPixelValue,
    maxPixelValue
  };
}
349984
function rgb2hcl(pixel) {
  const red = rgb2xyz(pixel[0]);
  const green = rgb2xyz(pixel[1]);
  const blue = rgb2xyz(pixel[2]);

  const x = xyz2lab(
    (0.4124564 * red + 0.3575761 * green + 0.1804375 * blue) / Xn);
  const y = xyz2lab(
    (0.2126729 * red + 0.7151522 * green + 0.0721750 * blue) / Yn);
  const z = xyz2lab(
    (0.0193339 * red + 0.1191920 * green + 0.9503041 * blue) / Zn);

  const l = 116 * y - 16;
  const a = 500 * (x - y);
  const b = 200 * (y - z);

  const c = Math.sqrt(a * a + b * b);
  let h = Math.atan2(b, a);
  if (h < 0) {
    h += twoPi;
  }

  pixel[0] = h;
  pixel[1] = c;
  pixel[2] = l;

  return pixel;
}
83778
def pixel(self, x, y, size=None):
        """"""
        if (size is None):
            size = self.sz
        # Have we go to the smallest element?
        if (size <= 3):
            if (_middle(x, y)):
                return (None)
            else:
                return (0, 0, 0)
        divisor = size // 3
        if (_middle(x // divisor, y // divisor)):
            return None
        return self.pixel(x % divisor, y % divisor, divisor)
136417
def rgb2gray(rgb):
    

    w = sla.atleast_nd(rgb.ndim, np.array([0.299, 0.587, 0.144],
                                          dtype=rgb.dtype, ndmin=3))
    return np.sum(w * rgb, axis=2)
505411
public float getFloatPixelValue(GriddedTile griddedTile, Double value) {

		double pixel = 0;
		if (value == null) {
			if (griddedCoverage != null) {
				pixel = griddedCoverage.getDataNull();
			}
		} else {
			pixel = valueToPixelValue(griddedTile, value);
		}

		float pixelValue = (float) pixel;

		return pixelValue;
	}
318131
def pixels_to_points(vertices)
      col_start, row_start, x1,    y1,
      col_end,   row_end,   x2,    y2,
      left,      top,       width, height  = vertices.flatten

      left   *= 0.75
      top    *= 0.75
      width  *= 0.75
      height *= 0.75

      [left, top, width, height]
    end
153301
def convertPixelXYToLngLat(self, pixelX, pixelY, level):
        '''
        
        '''
        mapSize = self.getMapDimensionsByZoomLevel(level)
        x = (self.clipValue(pixelX, 0, mapSize - 1) / mapSize) - 0.5
        y = 0.5 - (self.clipValue(pixelY, 0, mapSize - 1) / mapSize)

        lat = 90 - 360 * math.atan(math.exp(-y * 2 * math.pi)) / math.pi
        lng = 360 * x

        return (lng, lat)
893881
def nan_pixels(self):
        
        nan_px = np.where(np.isnan(np.sum(self.raw_data, axis=2)))
        nan_px = np.c_[nan_px[0], nan_px[1]]
        return nan_px
854566
def RGB(self, val):
        """"""
        # need to convert to normalized float
        val = np.atleast_1d(val).astype(np.float32) / 255.
        self.rgba = val
911142
def to_type_with_rgb(dest)
      if typecode < RGB_
        if dest < FLOAT_
          lazy { r * 0.299 + g * 0.587 + b * 0.114 }.to_type dest
        elsif dest < INT_
          lazy { (r * 0.299 + g * 0.587 + b * 0.114).round }.to_type dest
        else
          to_type_without_rgb dest
        end
      else
        to_type_without_rgb dest
      end
    end
1132770
def affine(self, pixelbuffer=0):
        
        return Affine(
            self.pixel_x_size,
            0,
            self.bounds(pixelbuffer).left,
            0,
            -self.pixel_y_size,
            self.bounds(pixelbuffer).top
        )
426766
public static float pixelToSip(Context context, float pixels) {
        DisplayMetrics metrics = new DisplayMetrics();
        float scaledDensity = metrics.scaledDensity;
        if (pixels == 0 || scaledDensity == 0) {
            return 1;
        }
        return pixels/scaledDensity;
    }
961026
def lfprob (dfnum, dfden, F):
    
    p = betai(0.5*dfden, 0.5*dfnum, dfden/float(dfden+dfnum*F))
    return p
205964
function hcl2rgb(pixel) {
  const h = pixel[0];
  const c = pixel[1];
  const l = pixel[2];

  const a = Math.cos(h) * c;
  const b = Math.sin(h) * c;

  let y = (l + 16) / 116;
  let x = isNaN(a) ? y : y + a / 500;
  let z = isNaN(b) ? y : y - b / 200;

  y = Yn * lab2xyz(y);
  x = Xn * lab2xyz(x);
  z = Zn * lab2xyz(z);

  pixel[0] = xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);
  pixel[1] = xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);
  pixel[2] = xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);

  return pixel;
}
588321
def pixels(self, zoom=None):
        """"""
        meter_x, meter_y = self.meters
        pixel_x = (meter_x + ORIGIN_SHIFT) / resolution(zoom=zoom)
        pixel_y = (meter_y - ORIGIN_SHIFT) / resolution(zoom=zoom)
        return abs(round(pixel_x)), abs(round(pixel_y))