Basic Image Processing with Python
Learn basic image processing techniques using Python’s built-in libraries with practical examples.
- Load image:
from PIL import Image
img = Image.open('image.jpg')
- Convert to grayscale:
gray_img = img.convert('L')
- Resize image:
resized = img.resize((256, 256))
- Apply filters:
from PIL import ImageFilter
blurred = img.filter(ImageFilter.BLUR)
sharpened = img.filter(ImageFilter.SHARPEN)
- Save processed image:
resized.save('processed.jpg')
Advanced techniques:
- Edge detection
- Histogram equalization
- Image segmentation
- Feature extraction
- Object detection
Read more: Pillow Documentation