โ† Back to MATLAB Part 1

MATLAB โ€“ Part 2

Interactive Image Processing with Lenna

1. Original Lenna Image

We will use the classic Lenna image to explore MATLAB image processing:

Original Lenna Image

2. Convert to Grayscale

grayImg = rgb2gray(img);
imshow(grayImg)
title('Grayscale Lenna')
Grayscale Lenna
๐Ÿ’ก Grayscale images simplify processing โ€” only one intensity channel is used.

3. Simple Binarization (Black & White)

bwImg = imbinarize(grayImg);
imshow(bwImg)
title('Binary Lenna')
Binary Lenna
โœ… Converts grayscale to pure black-and-white pixels for easy segmentation.

4. Edge Detection

Sobel Method:

edgesImg = edge(grayImg, 'Sobel');
imshow(edgesImg)
Sobel Edge

Canny Method (Cleaner edges):

edgesCanny = edge(grayImg, 'Canny');
imshow(edgesCanny)
Canny Edge

5. Histogram of Grayscale Intensities

figure
imhist(grayImg)
title('Histogram of Grayscale Lenna')
Histogram

Shows distribution of brightness values in the image.

6. Resize & Save Image

smallImg = imresize(grayImg, 0.5);
imshow(smallImg)
imwrite(smallImg, 'Lenna_small.png')

Next Steps