exercise

7
Exercise On lab1

Upload: tola

Post on 04-Jan-2016

35 views

Category:

Documents


0 download

DESCRIPTION

Exercise. On lab1. NOTE. in C++ : // the comment is placed here, and colored in green Or /* placed here, and colored in green */ Comment in matlab : % the comment is placed between percentage sign, and colored in green %. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Exercise

Exercise

On lab1

Page 2: Exercise

NOTE

• in C++ :

// the comment is placed here, and colored in green

Or

/* placed here, and colored in green */• Comment in matlab:% the comment is placed between percentage sign, and colored in green %

Page 3: Exercise

• Read the image, convert it to grayscale image, and resize it to 512X512

• apply the sampling equation so that the image is resized by factors of 2 to reach 64X64.

• Quantize the same image by reducing the gray levels by factors of 2 to reach 64X64.

Page 4: Exercise

Read the image, convert it to grayscale image, and resize it to 512X512.

I = imread(‘……..’); % read%

I1 = rgb2gray(I); % convert to grayscale %

M = imresize(I1,[512 512]); % resize%

Page 5: Exercise

apply the sampling equation so that the image is resized by factors of 2 to reach 64X64.

• 512 (29) 256 (28) 128 (27) 64(26) , So:• J = imresize(M, .5); % 512/2=256 %• K = imresize(J, .5); % 256/2=128 %• L = imresize(K, .5); % 128/2=64 %

The first parameter is different in each resize step,and taken from the previous step.

Page 6: Exercise

Quantize the same image by reducing the gray levels by factors of 2 to reach 64X64.

NOTE: in quantization always start from the image size. The image size in this example is 512

X1 = floor(M/2)*2; % 512/2 = 256 gray levels%

X2 = floor(M/4)*4; % 512/4 = 128 gray level%

X3 = floor(M/8)*8; % 512/8 = 64 gray level%

This parameter is always the same,and represents the image size before the sampling

This should be factors of 2when it is increase, the gray levels is decrease, and vise versa.

Page 7: Exercise

NOTE

22 23 24 25 26 27 28 29 210

4 8 16 32 64 128

256 5121024

Factors of 2