Lab 8 DSP
Lab 8 DSP
Lab 8 DSP
-------------------------LAB 08----------------------
Lab Exercise:
Task #1: Type in the command window
This will give you a list of, amongst other things; the entire sample TIFF images which come
with the Image Processing Toolbox. Make a list of these sample images, and for each image
SOLUTION:
MATLAB CODE:
help imdemos
(A) x=imread('macaw.jfif');
imshow(x)
imfinfo ('macaw. jfif')
OUTPUT:
impixel(x)
ans =
Task #2: Pick any grayscale image. Using the imwrite function, write it to files of type JPEG,
PNG and BMP. What are the sizes of those files?
SOLUTION:
MATLAB CODE:
y=imread('grayscale.png');
imshow(y)
imfinfo('grayscale.png')
OUTPUT:
FileSize: 20418
Format: 'png'
FormatVersion: []
Width: 150
Height: 200
BitDepth: 8
ColorType: 'grayscale'
Colormap: []
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: []
RenderingIntent: []
Chromaticities: []
Gamma: []
XResolution: []
YResolution: []
ResolutionUnit: []
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: []
Title: []
Author: []
Description: []
Copyright: []
CreationTime: []
Software: []
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: []
Task #3: Import any color image and extract out the red, green and blue color from it.
SOLUTION:
MATLAB CODE:
a=imread('macaw colorful.jpg');
r=a(:,:,1);g=a(:,:,2);b=a(:,:,3);
subplot(2,2,1);imshow(a);title('ORIGINAL IMAGE');
Task #4: Design the following images through MATLAB, by using loops, trigonometric
functions and matrices:
(b)SOLUTION:
MATLAB CODE:
for m=1:50; for n=1:50;
if m-n==0; z(m,n)=0;
elseif abs(m-n)==1 z(m,n)=0.5;
else z(m,n)=1;end
end
end
y=fliplr(z); subplot(2,1,1); imshow(z);
title('a)'); subplot(2,1,2); imshow(y); title('b)');
OUTPUT:
(a) SOLUTION:
MATLAB CODE:
a=ones(1,100);
b=zeros(1,100);
for c=1:100
if (-1)^c==1
z(c,:)=a;
else
z(c,:)=b;
end
end
imshow(z);
OUTPUT:
(d)SOLUTION:
MATLAB CODE:
a=ones(100,1);
b=zeros(100,1);
for c=1:100
if (-1)^c==1
z(:,c)=a;
else
z(:,c)=b;
end
end
imshow(z)
OUTPUT:
(e)
(f)
SOLUTION:
MATLAB CODE:
for m=1:100; for k=0; for n=1:1000; q(m,n)=k; k=k+0.0010; end end end
p=fliplr(q);subplot(2,1,1);imshow(q) subplot(2,1,2);imshow(p)
OUTPUT:
8.3 Conclusion
As a result, in this lab, we demonstrate the idea of image processing by executing various
MATLAB commands.