Did I find the right examples for you? yes no

All Samples(29)  |  Call(29)  |  Derive(0)  |  Import(0)
Maximize (normalize) image contrast. This function calculates a
histogram of the input image, removes **cutoff** percent of the
lightest and darkest pixels from the histogram, and remaps the image
so that the darkest pixel becomes black (0), and the lightest
becomes white (255).

:param image: The image to process.
:param cutoff: How many percent to cut off from the histogram.
:param ignore: The background pixel value (use None for no background).
:return: An image.

        def autocontrast(image, cutoff=0, ignore=None):
    """
    Maximize (normalize) image contrast. This function calculates a
    histogram of the input image, removes **cutoff** percent of the
    lightest and darkest pixels from the histogram, and remaps the image
    so that the darkest pixel becomes black (0), and the lightest
    becomes white (255).

    :param image: The image to process.
    :param cutoff: How many percent to cut off from the histogram.
    :param ignore: The background pixel value (use None for no background).
    :return: An image.
    """
    histogram = image.histogram()
    lut = []
    for layer in range(0, len(histogram), 256):
        h = histogram[layer:layer+256]
        if ignore is not None:
            # get rid of outliers
            try:
                h[ignore] = 0
            except TypeError:
                # assume sequence
                for ix in ignore:
                    h[ix] = 0
        if cutoff:
            # cut off pixels from both ends of the histogram
            # get number of pixels
            n = 0
            for ix in range(256):
                n = n + h[ix]
            # remove cutoff% pixels from the low end
            cut = n * cutoff // 100
            for lo in range(256):
                if cut > h[lo]:
                    cut = cut - h[lo]
                    h[lo] = 0
                else:
                    h[lo] = h[lo] - cut
                    cut = 0
                if cut <= 0:
                    break
            # remove cutoff% samples from the hi end
            cut = n * cutoff // 100
            for hi in range(255, -1, -1):
                if cut > h[hi]:
                    cut = cut - h[hi]
                    h[hi] = 0
                else:
                    h[hi] = h[hi] - cut
                    cut = 0
                if cut <= 0:
                    break
        # find lowest/highest samples after preprocessing
        for lo in range(256):
            if h[lo]:
                break
        for hi in range(255, -1, -1):
            if h[hi]:
                break
        if hi <= lo:
            # don't bother
            lut.extend(list(range(256)))
        else:
            scale = 255.0 / (hi - lo)
            offset = -lo * scale
            for ix in range(256):
                ix = int(ix * scale + offset)
                if ix < 0:
                    ix = 0
                elif ix > 255:
                    ix = 255
                lut.append(ix)
    return _lut(image, lut)
        


src/i/n/instakit-0.1.7/instakit/processors/adjust.py   instakit(Download)
    def process(self, img):
        return ImageOps.autocontrast(img,
            cutoff=self.cutoff,
            ignore=self.ignore)
 

src/n/u/nupic-HEAD/py/regions/ImageSensorFilters/NormalizeContrast.py   nupic(Download)
      alpha = croppedImage.split()[1]
      croppedImage = \
        ImageOps.autocontrast(croppedImage.split()[0], cutoff=self.cutoff)
      croppedImage.putalpha(alpha)
      image.paste(croppedImage, image.bbox)
      # Equalize the composite image
      compositeImage = \
        ImageOps.autocontrast(compositeImage.split()[0], cutoff=self.cutoff)
      # Paste the part of the equalized image within the mask back
      # into the cropped image
    elif self.region == 'all':
      alpha = image.split()[1]
      image = ImageOps.autocontrast(image.split()[0], cutoff=self.cutoff)
      image.putalpha(alpha)
    return image

src/d/j/django-tint-0.1/tint/imageprocs/default.py   django-tint(Download)
    def autocontrast(self, image, params):
        return ImageOps.autocontrast(image, params.get('cutoff', 0))
 
    def equalize(self, image, params):
        return ImageOps.equalize(image)

src/d/j/django-tint-HEAD/tint/imageprocs/default.py   django-tint(Download)
    def autocontrast(self, image, params):
        return ImageOps.autocontrast(image, params.get('cutoff', 0))
 
    def equalize(self, image, params):
        return ImageOps.equalize(image)

src/m/c/mcomix-HEAD/mcomix/image_tools.py   mcomix(Download)
        im = ImageEnhance.Brightness(im).enhance(brightness)
    if autocontrast and im.mode in ('L', 'RGB'):
        im = ImageOps.autocontrast(im, cutoff=0.1)
    elif contrast != 1.0:
        im = ImageEnhance.Contrast(im).enhance(contrast)

src/f/a/Facial-detection-HEAD/face_detect.py   Facial-detection(Download)
			im = im.crop((f.x-50, f.y-50, f.x+f.width+50, f.y+f.height+50))
			# Minor contrast adjustment
			im = ImageOps.autocontrast(im, cutoff=0.5)
			im.load()
			crop = '%s/%s_crop_%s.jpg' % (CROP_DIR, os.path.basename(file), i)

src/p/y/pyphant1-HEAD/src/workers/ImageProcessing/ImageProcessing/OptimalContrastWorker.py   pyphant1(Download)
    def optimizeContrast(self, subscriber, image):
        im = image.getSliceAsImage()
        co = self.paramCutoff.value
        result = ImageOps.autocontrast(im, co)
        return DataContainer.DataContainer(result, image.units)

src/p/y/pyphant.imageprocessing-1.0b3/ImageProcessing/OptimalContrastWorker.py   pyphant.imageprocessing(Download)
    def optimizeContrast(self, subscriber, image):
        im = image.getSliceAsImage()
        co = self.paramCutoff.value
        result = ImageOps.autocontrast(im, co)
        return DataContainer.DataContainer(result, image.units)

src/k/c/kcc-HEAD/kcc/image.py   kcc(Download)
                gamma = 1.0
        if gamma == 1.0:
            self.image = ImageOps.autocontrast(self.image)
        else:
            self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: 255 * (a / 255.) ** gamma))

src/m/i/Minitel-HEAD/mtimage.py   Minitel(Download)
        im = im.resize((w,h),Image.ANTIALIAS)
        # normalize contrast
        im = ImageOps.autocontrast(im)
        # down to 3-bit
        im = ImageOps.posterize(im,3)

  1 | 2  Next