T
T
tetrafishka2017-07-03 17:05:10
Python
tetrafishka, 2017-07-03 17:05:10

Apply smooth blur to a part of an image?

Hello! can you tell me how to apply blur smoothly from top to bottom
0844de763a314392b35d9530aaf4db71.png

def blur_filter(image):
    img = Image.open(os.path.join(ROOT_DIR, image))
    if img.mode != 'RGBA':
        img = img.convert('RGBA')
    width, height = img.size

    box = (0, height // 100 * 20, width, height // 100 * 60)
    img_box = img.crop(box)

    img = img.filter(ImageFilter.GaussianBlur(2))

    #imgt = Image.new('RGBA', (width, height), color=0xFFFFFF)
    #imgt.paste(img_box, box)
    #img = Image.blend(img, imgt, .1)

    img.save(os.path.join(ROOT_DIR, image.replace('/', '/copy_')), 'PNG')


if __name__ == '__main__':
    img_1 = 'img/9.jpg'
    img_2 = 'img/8.jpg'

    blur_filter(img_1)
    print('='*20)
    blur_filter(img_2)

I tried to cut out the part that needs to be filtered, but nothing happened.
I would be very grateful for your help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question