An |Image| object providing access to the properties and bytes of the
        image in this picture shape.
542290
def image(self):
        
        slide_part, rId = self.part, self._element.blip_rId
        if rId is None:
            raise ValueError('no embedded image')
        return slide_part.get_image(rId)
462970
def _pixel_data(image):
    
    # Test for PIL.Image and numpy.ndarray without requiring that cv2 or PIL
    # are installed.
    if 'PIL.' in str(type(image)):
        pixels = image.tobytes()
        width, height = image.size
    elif 'numpy.ndarray' in str(type(image)):
        if 'uint8' != str(image.dtype):
            image = image.astype('uint8')
        try:
            pixels = image.tobytes()
        except AttributeError:
            # `numpy.ndarray.tobytes()` introduced in `numpy` 1.9.0 - use the
            # older `tostring` method.
            pixels = image.tostring()
        height, width = image.shape[:2]
    else:
        # image should be a tuple (pixels, width, height)
        pixels, width, height = image

        # Check dimensions
        if 0 != len(pixels) % (width * height):
            raise PyLibDMTXError(
                (
                    'Inconsistent dimensions: image data of {0} bytes is not '
                    'divisible by (width x height = {1})'
                ).format(len(pixels), (width * height))
            )

    # Compute bits-per-pixel
    bpp = 8 * len(pixels) // (width * height)
    if bpp not in _PACK_ORDER:
        raise PyLibDMTXError(
            'Unsupported bits-per-pixel: [{0}] Should be one of {1}'.format(
                bpp, sorted(_PACK_ORDER.keys())
            )
        )

    return pixels, width, height, bpp
966276
function storedPixelDataToImageData (image) {
  // Transfer image data to alpha channel of WebGL texture
  // Store data in Uint8Array
  const pixelData = image.getPixelData();
  const numberOfChannels = 2;
  const data = new Uint8Array(image.width * image.height * numberOfChannels);
  let offset = 0;

  for (let i = 0; i < pixelData.length; i++) {
    data[offset++] = pixelData[i];
    data[offset++] = pixelData[i] < 0 ? 0 : 1; // 0 For negative, 1 for positive
  }

  return data;
}
664866
def display(self, image):
        
        assert(image.size == self.size)

        self.image = self.preprocess(image).copy()
188271
def _parse(self, data):
        
        super(Image, self)._parse(data)
        self.height = data['height']
        self.type = data['type']
        self.width = data['width']
547309
function imageToImageData ( image ) {
	if ( image instanceof HTMLImageElement ) {
		// http://stackoverflow.com/a/3016076/229189
		if ( ! image.naturalWidth || ! image.naturalHeight || image.complete === false ) {
			throw new Error( "This this image hasn't finished loading: " + image.src );
		}

		const canvas = new Canvas( image.naturalWidth, image.naturalHeight );
		const ctx = canvas.getContext( '2d' );
		
		ctx.drawImage( image, 0, 0, canvas.width, canvas.height );

		const imageData = ctx.getImageData( 0, 0, canvas.width, canvas.height );

		if ( imageData.data && imageData.data.length ) {
			if ( typeof imageData.width === 'undefined' ) {
				imageData.width = image.naturalWidth;
			}

			if ( typeof imageData.height === 'undefined' ) {
				imageData.height = image.naturalHeight;
			}
		}
		
		return imageData;
	} else {
		throw new Error( 'This object does not seem to be an image.' );
		return;
	}
}
1290200
function Image(varargs) {
  var img = {
    channelnames: null
  };
  var args = slice(arguments);
  if(args.length == 1 && is.string(args[0])) {
    img = oiio.read(args[0]);
    if(typeof img == 'undefined') {
      throw new TypeError("Invalid image type");
    }
    img.path = args[0];
  } else if(args.length == 1 && is.instance(args[0], Image)) {
    img = extend({}, args[0]);
  } else if(args.length == 4) {
    if(is.array(args[0])) {
      img.data = new Buffer(args[0]);
    } else if(Buffer.isBuffer(args[0])) {
      img.data = args[0];
    } else {
      throw new TypeError("First argument must be buffer");
    }
    img.width = args[1];
    img.height = args[2];
    img.channels = args[3];
    img.path = null;
  } else if(args.length == 3) {
    img.width = args[0];
    img.height = args[1];
    img.channels = args[2];
    img.data = new Buffer(img.width * img.height * img.channels);
    img.path = null;
  } else {
    throw new Error("Invalid arguments");
  }
  if(typeof img == 'undefined') {
    throw new Error("Unable to open " + img.path + " with OpenImageIO");
  }
  /* Add anything returned in read to here explicitly */
  this.data = img.data;
  this.width = img.width;
  this.height = img.height;
  this.path = img.path;
  this.channels = img.channels;
  this.channelnames = img.channelnames;
  if(this.channelnames === null) {
    this.channelnames = this.channels == 3 ? "RGB" 
                     : this.channels == 4 ? "RGBA" 
                     : this.channels == 1 ? "I"
                     : Array(this.channels.length+1).join('C');
  }

}
361098
def _image_width(image):
    
    if not Image:
        raise Exception("Images manipulation require PIL")
    file = StringValue(image).value
    path = None
    try:
        width = sprite_images[file][0]
    except KeyError:
        width = 0
        if callable(STATIC_ROOT):
            try:
                _file, _storage = list(STATIC_ROOT(file))[0]
                path = _storage.open(_file)
            except:
                pass
        else:
            _path = os.path.join(STATIC_ROOT, file)
            if os.path.exists(_path):
                path = open(_path, 'rb')
        if path:
            image = Image.open(path)
            size = image.size
            width = size[0]
            sprite_images[file] = size
    return NumberValue(width, 'px')
249796
def image_box(center, shape, box):
    ''''''
    return tuple(slice_create(c, b, stop=s)
                 for c, s, b in zip(center, shape, box))
315684
public com.google.protobuf.ByteString
      getImageBytes() {
    java.lang.Object ref = image_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      image_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
1018209
def set_image(self, img, bgr=False):
        ''''''
        if not self.is_alive():
            return
        if not hasattr(img, 'shape'):
            img = np.asarray(img[:,:])
        if bgr:
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        self.in_queue.put(MPImageData(img))
879872
def slice_image(image, axis=None, idx=None):
    
    if image.dimension < 3:
        raise ValueError('image must have at least 3 dimensions')

    inpixeltype = image.pixeltype
    ndim = image.dimension
    if image.pixeltype != 'float':
        image = image.clone('float')

    libfn = utils.get_lib_fn('sliceImageF%i' % ndim)
    itkimage = libfn(image.pointer, axis, idx)

    return iio.ANTsImage(pixeltype='float', dimension=ndim-1, 
                         components=image.components, pointer=itkimage).clone(inpixeltype)
641773
def _grab_raw_image(self):
        
        m = self.ale.getScreenRGB()
        return m.reshape((self.height, self.width, 3))
994738
def from_image(cls, image):
        
        (w, h) = image.size

        # Thermal paper is 512 pixels wide
        if w > 512:
            ratio = 512. / w
            h = int(h * ratio)
            image = image.resize((512, h), Image.ANTIALIAS)
        if image.mode != '1':
            image = image.convert('1')

        pixels = np.array(list(image.getdata())).reshape(h, w)

        # Add white pixels so that image fits into bytes
        extra_rows = int(math.ceil(h / 24)) * 24 - h
        extra_pixels = np.ones((extra_rows, w), dtype=bool)
        pixels = np.vstack((pixels, extra_pixels))
        h += extra_rows
        nb_stripes = h / 24
        pixels = pixels.reshape(nb_stripes, 24, w).swapaxes(1, 2).reshape(-1, 8)

        nh = int(w / 256)
        nl = w % 256
        data = []

        pixels = np.invert(np.packbits(pixels))
        stripes = np.split(pixels, nb_stripes)

        for stripe in stripes:

            data.extend([
                ESC,
                42,  # *
                33,  # double density mode
                nl,
                nh])

            data.extend(stripe)
            data.extend([
                27,   # ESC
                74,   # J
                48])

        # account for double density mode
        height = h * 2
        return cls(data, height)
726546
def extract_feature(self, image, layer):
        

        img = image.astype(np.float32)
        # Substracting Image mean value
        img -= np.array((104.00698793, 116.66876762, 122.67891434))

        # make dims C x H x W for Caffe
        img = img.transpose((2, 0, 1))
        in_img = img[np.newaxis, :, :, :]

        self.net.blobs['data'].reshape(*in_img.shape)

        data_feat = self.net.forward_all(data=in_img, blobs=[layer])

        feature = data_feat[layer][0]

        # feature = (feature - feature.mean()) / feature.std()
        # feature /= np.linalg.norm(feature)
        return feature
104328
function() {
            if (!this._image instanceof IMSoftcrop.Image || !this._image.ready) {
                return;
            }

            var body = document.getElementsByTagName('body');
            var canvas = document.createElement('canvas');
            var ctx = canvas.getContext('2d');

            canvas.style.display = 'none';
            body[0].appendChild(canvas);

            canvas.width = this._image.w;
            canvas.height = this._image.h;
            canvas.style.width = this._image.w + 'px';
            canvas.style.height = this._image.h + 'px';

            ctx.drawImage(
                this._image.image,
                0, 0,
                this._image.w, this._image.h
            );

            var imageData = ctx.getImageData(0, 0, this._image.w, this._image.h);

            // Cleanup references
            ctx = null;
            body[0].removeChild(canvas);
            canvas = null;
            body[0] = null;
            body = null;

            return imageData;
        }
881678
def image(value, width='', height=''):
    
    style = ""
    if width:
        style += "width:%s" % width
    if height:
        style += "height:%s" % height
    data_dict = dict(src=value, style=style)
    return '<img src="%(src)s" style="%(style)s">' % data_dict