engrharis commited on
Commit
1765352
·
verified ·
1 Parent(s): 11b0939

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from PIL import Image, ImageEnhance
3
  import numpy as np
4
  from io import BytesIO
5
 
@@ -40,16 +40,15 @@ def apply_filter(img):
40
  s = s.point(lambda i: min(255, max(0, int(i * saturation))))
41
  img = Image.merge("HSV", (h, s, v)).convert("RGB")
42
 
43
- # Texture and sharpening approximation
44
  texture = 1 + 4 / 100
45
- sharpening = 1 + 18 / 100
46
  enhancer = ImageEnhance.Sharpness(img)
47
- img = enhancer.enhance(texture * sharpening)
48
 
49
- # Radius and detail (approximated using sharpening and clarity)
50
  radius = 1.2
51
  detail = 1 + 30 / 100
52
- img = img.filter(ImageEnhance.UnsharpMask(radius=radius, percent=detail * 100, threshold=3))
53
 
54
  return img
55
 
 
1
  import streamlit as st
2
+ from PIL import Image, ImageEnhance, ImageFilter
3
  import numpy as np
4
  from io import BytesIO
5
 
 
40
  s = s.point(lambda i: min(255, max(0, int(i * saturation))))
41
  img = Image.merge("HSV", (h, s, v)).convert("RGB")
42
 
43
+ # Texture approximation
44
  texture = 1 + 4 / 100
 
45
  enhancer = ImageEnhance.Sharpness(img)
46
+ img = enhancer.enhance(texture)
47
 
48
+ # Sharpening using UnsharpMask
49
  radius = 1.2
50
  detail = 1 + 30 / 100
51
+ img = img.filter(ImageFilter.UnsharpMask(radius=radius, percent=detail * 100, threshold=3))
52
 
53
  return img
54