0% found this document useful (0 votes)
25 views

'Apple - JPG' 'Orange - JPG' 'Apple - JPG' 'Orange - JPG': For For For

The document discusses different digital image processing techniques including adding and subtracting images using loops and vectorization. It shows how vectorization is much faster than using loops. It also demonstrates contrast stretching of a grayscale image to increase contrast by mapping its minimum and maximum pixel values to the full range from 0 to 255.

Uploaded by

Nida Waheed
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

'Apple - JPG' 'Orange - JPG' 'Apple - JPG' 'Orange - JPG': For For For

The document discusses different digital image processing techniques including adding and subtracting images using loops and vectorization. It shows how vectorization is much faster than using loops. It also demonstrates contrast stretching of a grayscale image to increase contrast by mapping its minimum and maximum pixel values to the full range from 0 to 255.

Uploaded by

Nida Waheed
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Digital Image Processing

Adding/Subtracting two images

Using loops Vectorization


apple = imread('apple.jpg'); apple=imread('apple.jpg');
orange = imread('orange.jpg'); orange=imread('orange.jpg');
tic
for i = 1 : size(apple, 1) tic
for j = 1 : size(apple, 2) output = (orange + apple ) / 2;
for k = 1 : size(apple, 3) toc
output(i, j, k) =
(apple(i, j, k) + orange(i, j, k))/2;
end
end;
end
toc

Elapsed Time : 0.540730 seconds. Elapsed Time : 0.006441 seconds.

Contrast Stretching
X = imread('flower.jpg'); %reading a grayscale image
figure(1);
imshow(X);
title('Original Image')
a = min(X(:)); %minimum pixel of image X
b = max(X(:)); %maximum pixel of image X
X= (X-a).*(255/(b-a));
figure(2);
imshow(X);
title('Contrast Streached Image');
Original Image Contrast Streached Image

You might also like