Professional Documents
Culture Documents
Dip Lab 2
Dip Lab 2
Dip Lab 2
Submitted To
Engr. Aamir Arsalan
Submitted By
Zeeshan Khlid
Registration No.
15-CP-104
September 17, 2017
LAB TASKS
Question#1:
What type of image is coins.png?
MATLAB CODE:
I=imread('coins.png');
imshow(I)
OUTPUT
OUTPUT
The output will be the matrix of the coin.png
Question#3
How many dimensions does the variable X_rgb have and what are their
sizes?
ANSWER:
It will give 258 rows and 350 columns.
September 17, 2017
Question#4
What class type is X_gray?
ANSWER:
It shows that X_gray is unsigned int: -
Question#5
Why are we required to use the colon operator when specifying the X_gray variable? What
happens if we omit it?
ANSWER:
If we remove colon operator, then every pixel’s information will be displayed.
Question#6
What is the range of values for the new variable X_gray_dbl?
ANSWER:
If we convert we get the range lies in 0 to 1.
Question#7
Consider an image where the range of possible values for each pixel is
not [0, 255], but a nonstandard range such as [0, 99]. How would we
display the image so that a value of 99 represents white and a value of
0 represents black?
September 17, 2017
Question#8
What is the meaning of the values stored in variables r, c, and p?
ANSWER:
As we see: -
r = Rows, c = Columns, p = RGB color
Question#9
What is the range of values for image A and image B?
MATLAB CODE:
clear all
clc
A = imread('pout.tif');
B = imread('cameraman.tif');
figure
subplot(1,2,1), imshow(A)
subplot(1,2,2), imshow(B)
September 17, 2017
OUTPUT
Question#10
What happened to the coins image just after the trees image was
displayed? Explain your answer.
MATLAB CODE:
clc
clear all
I = imread('coins.png');
[X,map] = imread('trees.tif');
figure
subplot(1,2,1), imshow(I)
subplot(1,2,2), imshow(X,map)
OUTPUT
September 17, 2017
This code will help you to get a coin.jpg without being affected.
Question#11
What do the variables I_ind and I_map contain?
ANSWER:
We indexed the image. It tells at certain location what is the value of map.
September 17, 2017
OUTPUT
September 17, 2017
2. Take any five images from MATLAB and collect the following
information about each of them:
• File name
• File format (extension)
• Type (binary, grayscale, true color, or indexed color)
• Size (bytes)
• Width (pixels)
• Height (pixels)
Select five images available in MATLAB (they may be the same as
from the previous problem, or not, you choose). Open each of
them
using imread, save it (using imwrite) to (at least three)
different file formats, and compare the resulting file size (in
bytes) for each output format
MATLAB CODE_PART_A:
A= imread('cameraman.tif');
B= imread('trees.tif');
C= imread('football.jpg');
D= imread('pout.tif');
E= imread('peppers.png');
subplot(3,2,1);
imshow(A)
subplot(3,2,2);
imshow(B)
subplot(3,2,3);
imshow(C)
subplot(3,2,4);
imshow(D)
subplot(3,2,5);
imshow(E)
imfinfo('cameraman.tif')
imfinfo('trees.tif')
imfinfo('football.jpg')
imfinfo('pout.tif')
imfinfo('peppers.png')
September 17, 2017
OUTPUT
September 17, 2017
September 17, 2017
September 17, 2017
MATLAB CODE_PART_B:
A= imread('football.jpg');
B= imread('trees.tif');
C= imread('kids.tif');
D= imread('moon.tif');
E= imread('peppers.png');
imwrite(A,'image_01.png');
subplot(10,2,1);
imshow('image_01.png');
imwrite(B,'image_02.png');
subplot(10,2,2);
imshow('image_02.png')
imwrite(C,'image_03.tif');
subplot(10,2,3);
imshow('image_03.tif')
imwrite(D,'image_04.png');
subplot(10,2,4);
imshow('image_04.png')
September 17, 2017
imwrite(E,'mage_05.tif');
subplot(10,2,5);
imshow('image_05.tif')
imwrite(A,'image_01.tif');
subplot(10,2,6);
imshow('image_01.tif')
imwrite(B,'image_02.jpg');
subplot(10,2,7);
imshow('image_02.jpg')
imwrite(C,'image_03.jpg');
subplot(10,2,8);
imshow('image_03.jpg')
imwrite(D,'image_04.jpg');
subplot(10,2,9);
imshow('image_04.jpg')
imwrite(E,'image_05.jpg');
subplot(10,2,10);
imshow('image_05.jpg')
imwrite(A,'image_01.jpg');
subplot(10,2,11);
imshow('image_01.jpg')
imwrite(B,'image_02.tif');
subplot(10,2,12);
imshow('image_02.tif')
imwrite(C,'image_03.png');
subplot(10,2,13);
imshow('image_03.png')
imwrite(D,'image_04.tif');
subplot(10,2,14);
imshow('image_04.tif')
imwrite(E,'image_05.png');
subplot(10,2,15);
imshow('image_05.png')
OUTPUT