Пример #1
0
 def read_acv(self, name):
     print "Reading curves from %s.acv" % name
     acv_path = static.path('acv', "%s.acv" % name)
     with open(acv_path, "rb") as acv_file:
         _, self.count = unpack("!hh", acv_file.read(4))
         for i in xrange(self.count):
             self.curves.append(
                 self.read_one_curve(acv_file, self.channel_name(i)))
Пример #2
0
 def read_acv(self, name):
     print "Reading curves from %s.acv" % name
     acv_path = static.path(
         'acv', "%s.acv" % name)
     with open(acv_path, "rb") as acv_file:
         _, self.count = unpack("!hh", acv_file.read(4))
         for i in xrange(self.count):
             self.curves.append(
                 self.read_one_curve(
                     acv_file, self.channel_name(i)))
Пример #3
0
        self.n = n
        if nY is not None:
            self.nY = nY
        else:
            self.nY = n
    
    def process(self, img):
        import numpy
        from PIL import Image
        out = kernels.gaussian_blur_filter(
            numpy.array(img),
            sigma=self.n)
        return Image.fromarray(out)

if __name__ == '__main__':
    from PIL import Image
    from django_instakit.utils import static
    
    image_paths = map(
        lambda image_file: static.path('img', image_file),
            static.listfiles('img'))
    image_inputs = map(
        lambda image_path: Image.open(image_path).convert('RGB'),
            image_paths)
    
    for image_input in image_inputs:
        image_input.show()
        GaussianBlur(n=3).process(image_input).show()
    
    print image_paths
    
Пример #4
0
            right -= remove
            diff_x = diff_x - add - remove

        while diff_y:
            slice = min(diff_y, max(diff_y // 5, 10))
            start = img.crop((0, top, source_x, top + slice))
            end = img.crop((0, bottom - slice, source_x, bottom))
            add, remove = self.compare_entropy(start, end, slice, diff_y)
            top += add
            bottom -= remove
            diff_y = diff_y - add - remove

        box = (left, top, right, bottom)
        img = img.crop(box)
        return img


if __name__ == '__main__':
    from django_instakit.utils import static

    image_paths = map(lambda image_file: static.path('img', image_file),
                      static.listfiles('img'))
    image_inputs = map(
        lambda image_path: Image.open(image_path).convert('RGB'), image_paths)

    for image_input in image_inputs:
        image_input.show()
        SquareCrop().process(image_input).show()

    print image_paths