examples.rst 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 30
  40. noisy_image = nf.gaussian_noise(img, n=30)
  41. output = Image.fromarray(noisy_image)
  42. output.show()
  43. Image result after applying gaussian noise on nature image.
  44. .. image:: _static/nature_gaussian_noise.png