예제 #1
0
def blurthday():

    from imread import imread
    from pprint import pprint
    imfuckingshowalready = lambda mx: Image.fromarray(mx).show()

    identity = LUT()
    amatorka = LUT('amatorka')
    #miss_etikate = LUT('miss_etikate')
    #soft_elegance_1 = LUT('soft_elegance_1')
    #soft_elegance_2 = LUT('soft_elegance_2')

    im1 = imread(static.path(join('img', '06-DSCN4771.JPG')))
    im2 = imread(
        static.path(
            join('img',
                 '430023_3625646599363_1219964362_3676052_834528487_n.jpg')))

    pprint(identity)
    pprint(amatorka)

    im9 = amatorka.transform(im1)
    pprint(im9)
    imfuckingshowalready(im9)
    print im1
    print im2
예제 #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
 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)))
예제 #4
0
파일: lutmap.py 프로젝트: fladi/instakit
def blurthday():
    
    from imread import imread
    from pprint import pprint
    imfuckingshowalready = lambda mx: Image.fromarray(mx).show()
    
    identity = LUT()
    amatorka = LUT('amatorka')
    #miss_etikate = LUT('miss_etikate')
    #soft_elegance_1 = LUT('soft_elegance_1')
    #soft_elegance_2 = LUT('soft_elegance_2')
    
    im1 = imread(static.path(join('img', '06-DSCN4771.JPG')))
    im2 = imread(static.path(join(
        'img', '430023_3625646599363_1219964362_3676052_834528487_n.jpg')))
    
    pprint(identity)
    pprint(amatorka)
    
    im9 = amatorka.transform(im1)
    pprint(im9)
    imfuckingshowalready(im9)
    print im1
    print im2
예제 #5
0
파일: lutmap.py 프로젝트: fladi/instakit
def old_main():
    
    #imfuckingshowalready = lambda mx: Image.fromarray(mx).show()

    old_identity = static.path(join('lut', 'identity.png'))

    im_old_identity = imread.imread(old_identity)
    im_identity = numpy.zeros_like(im_old_identity)

    for bx in xrange(0, 8):
        for by in xrange(0, 8):
            for r in xrange(0, 64):
                for g in xrange(0, 64):
                    im_identity[
                        int(g + by * 64),
                        int(r + bx * 64)] = numpy.array((
                            int(r * 255.0 / 63.0 + 0.5),
                            int(g * 255.0 / 63.0 + 0.5),
                                int((bx + by * 8.0) * 255.0 / 63.0 + 0.5)),
                                dtype=numpy.uint8)
    
    print "THE OLD: %s, %s, %s" % (
        im_old_identity.size, im_old_identity.shape,
        str(im_old_identity.dtype))
    #print im_old_identity
    print ""
    
    print "THE NEW: %s, %s, %s" % (
        im_identity.size, im_identity.shape,
        str(im_identity.dtype))
    #print im_identity
    print ""
    
    
    
    print "THE END: %s" % bool(im_old_identity.shape == im_identity.shape)
    #print im_old_identity == im_identity
    
    #imfuckingshowalready(im_identity)
    #imfuckingshowalready(im_old_identity)
    
    pil_im_old_identity = Image.fromarray(im_old_identity)
    pil_im_old_identity.save('/tmp/im_old_identity.jpg',
        format="JPEG")
    
    pil_im_identity = Image.fromarray(im_identity)
    pil_im_identity.save('/tmp/im_identity.jpg',
        format="JPEG")
예제 #6
0
def old_main():

    #imfuckingshowalready = lambda mx: Image.fromarray(mx).show()

    old_identity = static.path(join('lut', 'identity.png'))

    im_old_identity = imread.imread(old_identity)
    im_identity = numpy.zeros_like(im_old_identity)

    for bx in xrange(0, 8):
        for by in xrange(0, 8):
            for r in xrange(0, 64):
                for g in xrange(0, 64):
                    im_identity[int(g + by * 64),
                                int(r + bx * 64)] = numpy.array(
                                    (int(r * 255.0 / 63.0 + 0.5),
                                     int(g * 255.0 / 63.0 + 0.5),
                                     int((bx + by * 8.0) * 255.0 / 63.0 +
                                         0.5)),
                                    dtype=numpy.uint8)

    print "THE OLD: %s, %s, %s" % (im_old_identity.size, im_old_identity.shape,
                                   str(im_old_identity.dtype))
    #print im_old_identity
    print ""

    print "THE NEW: %s, %s, %s" % (im_identity.size, im_identity.shape,
                                   str(im_identity.dtype))
    #print im_identity
    print ""

    print "THE END: %s" % bool(im_old_identity.shape == im_identity.shape)
    #print im_old_identity == im_identity

    #imfuckingshowalready(im_identity)
    #imfuckingshowalready(im_old_identity)

    pil_im_old_identity = Image.fromarray(im_old_identity)
    pil_im_old_identity.save('/tmp/im_old_identity.jpg', format="JPEG")

    pil_im_identity = Image.fromarray(im_identity)
    pil_im_identity.save('/tmp/im_identity.jpg', format="JPEG")
예제 #7
0
    
    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 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()
        Contour().process(image_input).show()
        Detail().process(image_input).show()
        Emboss().process(image_input).show()
        EdgeEnhance().process(image_input).show()
        EdgeEnhanceMore().process(image_input).show()
        FindEdges().process(image_input).show()
        Smooth().process(image_input).show()
예제 #8
0
            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 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()
        Contour().process(image_input).show()
        Detail().process(image_input).show()
        Emboss().process(image_input).show()
        EdgeEnhance().process(image_input).show()
        EdgeEnhanceMore().process(image_input).show()
        FindEdges().process(image_input).show()
        Smooth().process(image_input).show()
        SmoothMore().process(image_input).show()
예제 #9
0
 def _read_png_matrix(cls, name):
     print "Reading LUT image: %s" % static.path(
         join('lut', '%s.png' % name))
     return imread.imread(static.path(join('lut', '%s.png' % name)))
예제 #10
0
파일: lutmap.py 프로젝트: fladi/instakit
 def _read_png_matrix(cls, name):
     print "Reading LUT image: %s" % static.path(join('lut', '%s.png' % name))
     return imread.imread(
         static.path(join('lut', '%s.png' % name)))
예제 #11
0
class SaltAndPepperNoise(Noise):
    """ Add 'salt and pepper noise' -- replace random pixel values with 1.0f (255) or zero """
    mode = 's&p'

class SpeckleNoise(Noise):
    """ Add multiplicative noise using out = image + n*image
        (where n is uniform noise with specified mean & variance) """
    mode = 'speckle'


if __name__ == '__main__':
    from PIL import Image
    from 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)
    
    noises = [
        GaussianNoise, PoissonNoise, GaussianLocalVarianceNoise,
        SaltNoise, PepperNoise, SaltAndPepperNoise, SpeckleNoise
    ]
    
    for idx, image_input in enumerate(image_inputs + image_inputs[:2]):
        image_input.show()
        #Noise().process(image_input).show()
        noises[idx]().process(image_input).show()