examples.rst.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Examples
  2. =====================================
  3. Some examples are already available into documentation. You can find here some others and results of use of IPFML package.
  4. All examples below will use this picture.
  5. .. image:: _static/nature.jpg
  6. Metrics example
  7. --------------------
  8. Using **metrics** module you can convert image into Lab, XYZ, SVD...
  9. .. code:: python
  10. from PIL import Image
  11. from ipfml import metrics
  12. img_path = 'path/to/image_nature.jpg'
  13. img = Image.open(img_path)
  14. s = metrics.get_LAB_L(img)
  15. # convert result into PIL Image
  16. output = Image.fromarray(s)
  17. output.show()
  18. This is the generated output using only L chanel from Lab.
  19. .. image:: _static/nature_lab_l.png
  20. Processing example
  21. --------------------
  22. .. code:: python
  23. from PIL import Image
  24. from ipfml import processing
  25. img_path = 'path/to/image_nature.jpg'
  26. img = Image.open(img_path)
  27. low_bits_img = processing.rgb_to_grey_low_bits(img, 6)
  28. output = Image.fromarray(low_bits_img)
  29. output.show()
  30. Now we have picture information with only the 6 low bits values.
  31. .. image:: _static/nature_low_bits_6.png
  32. Noise filter example
  33. ---------------------
  34. .. code:: python
  35. from PIL import Image
  36. from ipfml.filters import noise as nf
  37. img_path = 'path/to/image_nature.jpg'
  38. img = Image.open(img_path)
  39. # set noise impact to 400
  40. # set same noise for each chanel
  41. noisy_image = nf.gaussian_noise(img, n=400, identical=True)
  42. output = Image.fromarray(noisy_image)
  43. output.show()
  44. Image result after applying gaussian noise on nature image.
  45. .. image:: _static/nature_gaussian_noise.png