Advertisement
here2share

# b_image_line_tracing_to_text.py

Sep 13th, 2020
1,574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. # b_image_line_tracing_to_text.py
  2.  
  3. from PIL import Image, ImageTk
  4.  
  5. from tkFileDialog import askopenfilename
  6. img_data = askopenfilename(filetypes=[('png files', '.png')]) # needs to be placed after pack()
  7.  
  8. image = Image.open(img_data)
  9. w,h = image.size
  10. img = Image.new('RGB', (w,h))
  11. rgb = image.convert("RGB")
  12. sss = list(rgb.getdata())
  13. xxx = sss[:]
  14.  
  15. d = list(set(sss))
  16. d.sort()
  17. print d
  18. L = len(xxx)
  19.  
  20. while xxx:
  21.     x,xxx = xxx[:w],xxx[w:]
  22.     try:
  23.         i = x.index((255, 255, 255))   
  24.         print i,
  25.     except:
  26.         print w,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement