Can only be used with images that are NOT sub-images.
439877
public static void derivX_F32(GrayF32 orig,
								  GrayF32 derivX) {
		final float[] data = orig.data;
		final float[] imgX = derivX.data;

		final int width = orig.getWidth();
		final int height = orig.getHeight();

		for (int y = 0; y < height; y++) {
			int index = width * y + 1;
			int endX = index + width - 2;
			int endXAlt = endX - (width - 2) % 3;

			float x0 = data[index - 1];
			float x1 = data[index];

			for (; index < endXAlt;) {
				float x2 = data[index + 1];
				imgX[index++] = (x2 - x0) * 0.5f;
				x0 = data[index + 1];
				imgX[index++] = (x0 - x1) * 0.5f;
				x1 = data[index + 1];
				imgX[index++] = (x1 - x2) * 0.5f;
			}

			for (; index < endX; index++) {
				imgX[index] = (data[index + 1] - data[index - 1]) * 0.5f;
			}
		}
	}
1253259
def connect_to_images(region=None, public=True):
    """"""
    return _create_client(ep_name="image", region=region, public=public)
1288378
def mask_images(images: Iterable[SpatialImage], mask: np.ndarray,
                image_type: type = None) -> Iterable[np.ndarray]:
    
    for images in multimask_images(images, (mask,), image_type):
        yield images[0]
1081532
def allow_image_cropping?(options = {})
      content && content.settings_value(:crop, options) && picture &&
        picture.can_be_cropped_to(
          content.settings_value(:size, options),
          content.settings_value(:upsample, options)
        )
    end
23471
def crop_2dimage(img, beg_coords, end_coords):
    """"""

    cropped_img = img[
                  beg_coords[0]:end_coords[0],
                  beg_coords[1]:end_coords[1],
                  ]

    return cropped_img
1213643
def get_image(self, title, group):
        '''
        
        '''
        return self.images[group.lower()][title.lower()]
1273891
function _imageCopyResampledWorkaround2(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
    {
        ImagePaletteCopy($dst_img, $src_img);
        $rX = $src_w / $dst_w;
        $rY = $src_h / $dst_h;
        $w = 0;
        for ($y = $dst_y; $y < $dst_h; $y++)
        {
            $ow = $w;
            $w = round(($y + 1) * $rY);
            $t = 0;
            for ($x = $dst_x; $x < $dst_w; $x++)
            {
                $r = $g = $b = 0;
                $a = 0;
                $ot = $t;
                $t = round(($x + 1) * $rX);
                for ($u = 0; $u < ($w - $ow); $u++)
                {
                    for ($p = 0; $p < ($t - $ot); $p++)
                    {
                        $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
                        $r += $c['red'];
                        $g += $c['green'];
                        $b += $c['blue'];
                        $a++;
                    }
                }
                ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
            }
        }
    }
512850
function(image, options) {
        var index = options.imageMaskIndex || this.options.imageMaskIndex;
        if (!index)
            return;
        if (typeof index === 'function') {
            index = index(image, options);
        }
        return index;
    }
18704
def canRender(filename):
        """"""
        name, ext = os.path.splitext(filename)
        ext = ext.lstrip('.').lower()
        if ext in ImageRenderer._extensions:
            return 100
        else:
            return False
233995
def stretch(image, mask=None):
    '''
    '''
    image = np.array(image, float)
    if np.product(image.shape) == 0:
        return image
    if mask is None:
        minval = np.min(image)
        maxval = np.max(image)
        if minval == maxval:
            if minval < 0:
                return np.zeros_like(image)
            elif minval > 1:
                return np.ones_like(image)
            return image
        else:
            return (image - minval) / (maxval - minval)
    else:
        significant_pixels = image[mask]
        if significant_pixels.size == 0:
            return image
        minval = np.min(significant_pixels)
        maxval = np.max(significant_pixels)
        if minval == maxval:
            transformed_image = minval
        else:
            transformed_image = ((significant_pixels - minval) /
                                 (maxval - minval))
        result = image.copy()
        image[mask] = transformed_image
        return image
736062
def apply(self, resource):
        
        if not isinstance(resource, Image.Image):
            raise ValueError('Unsupported resource format: %s' % str(type(resource)))

        original_width, original_height = resource.size

        if original_width > self.size[0] or original_height > self.size[1]:
            k = original_width / original_height

            if original_width >= original_height:
                target_width = self.size[0]
                target_height = int(target_width / k)
            else:
                target_height = self.size[1]
                target_width = int(target_height * k)

            resource_format = resource.format
            resource = resource.resize((target_width, target_height), Image.ANTIALIAS)
            resource.format = resource_format

        return resource
1089534
def non_object_image
      image = list_item.image

      return image.file.url if image.respond_to?(:file)
      return image if image.present?

      fallback_image
    end
1132647
def imshow(image, auto_subplot=False, **kwargs):
        
        if isinstance(image, BinaryImage) or isinstance(image, GrayscaleImage):
            plt.imshow(image.data, cmap=plt.cm.gray, **kwargs)
        elif isinstance(image, ColorImage) or isinstance(image, SegmentationImage):
            plt.imshow(image.data, **kwargs)
        elif isinstance(image, DepthImage):
            plt.imshow(image.data, cmap=plt.cm.gray_r, **kwargs)
        elif isinstance(image, RgbdImage):
            if auto_subplot:
                plt.subplot(1,2,1)
                plt.imshow(image.color.data, **kwargs)
                plt.axis('off')
                plt.subplot(1,2,2)
                plt.imshow(image.depth.data, cmap=plt.cm.gray_r, **kwargs)
            else:
                plt.imshow(image.color.data, **kwargs)
        elif isinstance(image, GdImage):
            if auto_subplot:
                plt.subplot(1,2,1)
                plt.imshow(image.gray.data, cmap=plt.cm.gray, **kwargs)
                plt.axis('off')
                plt.subplot(1,2,2)
                plt.imshow(image.depth.data, cmap=plt.cm.gray_r, **kwargs)
            else:
                plt.imshow(image.gray.data, cmap=plt.cm.gray, **kwargs)
        plt.axis('off')
1129577
def oneImageNLF(img, img2=None, signal=None):
    '''
    
    '''
    x, y, weights, signal = calcNLF(img, img2, signal)
    _, fn, _ = _evaluate(x, y, weights)
    return fn, signal
1185255
def addImage(self, image, mask=None):
        '''
        
        '''
        self._last_diff = diff = image - self.noSTE

        ste = diff > self.threshold
        removeSinglePixels(ste)

        self.mask_clean = clean = ~ste

        if mask is not None:
            clean = np.logical_and(mask, clean)

        self.mma.update(image, clean)

        if self.save_ste_indices:
            self.mask_STE += ste

        return self
1006123
def baseimage(self, new_image):
        
        images = self.parent_images or [None]
        images[-1] = new_image
        self.parent_images = images
1058359
def combine(method, images, masks=None, dtype=None,
            region=None, zeros=None, scales=None, weights=None,
            include_variance=True, datamodel=None, method_name=""):
    """'"""

    import numina.datamodel

    nimages = len(images)

    # processing masks
    if masks is None:
        intl_masks = [None for _ in images]
    elif isinstance(masks, Extension):
        intl_masks = [img[masks.name].data for img in images]
    elif isinstance(masks, collections.Sequence):
        intl_masks = [mask[0].data for mask in masks]
    else:
        raise TypeError('mask in invalid')

    if len(intl_masks) != nimages:
        raise TypeError('len(masks) != len(images)')

    # Processing region
    if region is None:
        region = Ellipsis # meaning arr[...]

    # processing zeros, scales and weights
    num_values = dict(zeros=None, scales=None, weights=None)
    arg_values = dict(zeros=zeros, scales=scales, weights=weights)

    for key in num_values:
        arg = arg_values[key] # locals()[key]
        value_arg, arg_is_func = _inspect_method(arg)
        if arg_is_func:
            num_values[key] = [value_arg(img, mask, region) for img, mask in zip(images, intl_masks)]
        else:
            num_values[key] = value_arg
        if num_values[key] is not None:
            # Intl combine works only with np arrays
            num_values[key] = numpy.array(num_values[key])

    arrays = [hdu[0].data for hdu in images]
    if masks is None:
        fmasks = None
    else:
        fmasks = intl_masks

    out = C.generic_combine(
        method, arrays, masks=fmasks, dtype=dtype, out=None,
        zeros=num_values['zeros'], scales=num_values['scales'],
        weights=num_values['weights'])

    # Build HDUList
    headers = [img[0].header for img in images]

    base_header = headers[0].copy()
    hdu1 = fits.PrimaryHDU(data=out[0], header=base_header)
    list_of_hdu = [hdu1]

    #_logger.debug('update result header')
    prolog = ""
    if prolog:
        #_logger.debug('write prolog')
        hdu1.header['history'] = prolog

    if method_name != "":
        #_logger.info("Combined %d images using '%s'", nimages, method.__name__)
        hdu1.header['history'] = "Combined %d images using '%s'" % (nimages, method)
    else:
        hdu1.header['history'] = "Combined %d images" % (nimages,)

    hdu1.header['history'] = 'Combination time {}'.format(datetime.datetime.utcnow().isoformat())

    if datamodel is None:
        datamodel = numina.datamodel.DataModel()

    for idx, img in enumerate(images, start=1):
        hdu1.header['history'] = "Image{} {}".format(idx, datamodel.get_imgid(img))

    prevnum = base_header.get('NUM-NCOM', 1)

    hdu1.header['NUM-NCOM'] = prevnum * nimages
    hdu1.header['UUID'] = str(uuid.uuid1())

    # Headers of last image
    # hdu1.header['TSUTC2'] = headers[-1]['TSUTC2']

    if include_variance:
        varhdu = fits.ImageHDU(out[1], name='VARIANCE')
        list_of_hdu.append(varhdu)

    num = fits.ImageHDU(out[2].astype('uint8'), name='MAP')
    list_of_hdu.append(num)

    result = fits.HDUList(list_of_hdu)
    return result