image processing lab report sample

22
EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering EECE 253 IMAGE PROCESSING LABORATORY ASSIGNMENT 1 Wan Hisham Wan Ibrahim 8 September, 2013 Abstract This document reports the results of some experiments on the subsampling of digital images. Subsampling is a fast way to reduce the size of an image but its usefulness is limited by the distortion it causes in the result. Three experiments were performed to determine the visual effects on a 24-bit true-color image of downsampling through simple pixel copying without filtering or any other preprocessing. The first experiment determined that if all three color bands were uniformly downsampled then degradation was first noticeable at a downsample factor of 3. Extreme degradation occurred with a downsample factor of 5. The second experiment demonstrated the effect of downsampling image luminance while leaving color information untouched. This was done by pixelating the luminance – downsampling by a factor of k followed by upsampling through pixel replication by a factor of k. The visible results were essentially the same as those of the first experiment. The third experiment tested the effects of pixelating chrominance while leaving luminance unaltered. It was found that there was no visible degradation of the image until the chrominance was pixelated by a factor of 5. The distortion was highly noticeable at chrominance pixelation factors of 9 or more but the distortion resulting from chrominance pixelation never seemed as visually significant as that resulting from pixelation of the luminance. Introduction One of the most common procedures in digital image processing is the resizing of images. A fast and obvious way to make an image smaller is through downsampling: To resize an image by a factor of N/M in each dimension (where N < M) copy N 2 pixels from each M x M block in the original image to a new, smaller array. For example, if N=1 and M=3 then one could copy the pixel from every third column in every third row of the image. However, this simple method of resizing can lead to a significantly distorted results through aliasing. Such distortion usually appears as jagged stair-step edges, where there were smooth edges originally, or as Moiré patterns superimposed sets of straight or curving, perpendicular and parallel lines. The distortion increases with the downsampling factor but may not be significant for small factors. In this laboratory exercise, experiments were performed to determine the downsample factor for which distortion becomes significant. Two programs were written: one to downsample, through pixel copying, a 24-bit true- color image by an integer factor, the other to upsample an image by an integer factor through pixel replication. If one executes the downsampling program with factor k on an R C image, I, Wan Ibrahim 1 8 September, 2013

Upload: wan-hisham-wan-ibrahim

Post on 22-Oct-2015

47 views

Category:

Documents


2 download

DESCRIPTION

A sample of image processing lab report for EECE 253 with Alan Peters

TRANSCRIPT

Page 1: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

EECE 253 IMAGE PROCESSING

LABORATORY ASSIGNMENT 1

Wan Hisham Wan Ibrahim

8 September, 2013

Abstract

This document reports the results of some experiments on the subsampling of digital im-ages. Subsampling is a fast way to reduce the size of an image but its usefulness is limited by the distortion it causes in the result. Three experiments were performed to determine the visual effects on a 24-bit true-color image of downsampling through simple pixel copying without fil-tering or any other preprocessing. The first experiment determined that if all three color bands were uniformly downsampled then degradation was first noticeable at a downsample factor of 3. Extreme degradation occurred with a downsample factor of 5. The second experiment demon-strated the effect of downsampling image luminance while leaving color information untouched. This was done by pixelating the luminance – downsampling by a factor of k followed by upsam-pling through pixel replication by a factor of k. The visible results were essentially the same as those of the first experiment. The third experiment tested the effects of pixelating chrominance while leaving luminance unaltered. It was found that there was no visible degradation of the im-age until the chrominance was pixelated by a factor of 5. The distortion was highly noticeable at chrominance pixelation factors of 9 or more but the distortion resulting from chrominance pixelation never seemed as visually significant as that resulting from pixelation of the luminance.

IntroductionOne of the most common procedures in digital image processing is the resizing of im-

ages. A fast and obvious way to make an image smaller is through downsampling: To resize an image by a factor of N/M in each dimension (where N < M) copy N2 pixels from each M x M block in the original image to a new, smaller array. For example, if N=1 and M=3 then one could copy the pixel from every third column in every third row of the image. However, this simple method of resizing can lead to a significantly distorted results through aliasing. Such distortion usually appears as jagged stair-step edges, where there were smooth edges originally, or as Moiré patterns superimposed sets of straight or curving, perpendicular and parallel lines. The distortion increases with the downsampling factor but may not be significant for small fac-tors. In this laboratory exercise, experiments were performed to determine the downsample fac-tor for which distortion becomes significant.

Two programs were written: one to downsample, through pixel copying, a 24-bit true-color image by an integer factor, the other to upsample an image by an integer factor through pixel replication. If one executes the downsampling program with factor k on an R C image, I, the result is an image, J, of dimensions int(R/k) int (C/k), where int(x) is the largest integer less

Wan Ibrahim 1 8 September, 2013

Page 2: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

than or equal to x. If one then executes the upsampling program on image J, the result is an im-age, K, with dimensions kint(R/k) kint (C/k). Image K is a pixelated or mosaic approximation of image I.

The human visual system is not uniformly sensitive to image degradation. In particular, it is more sensitive to degradation of the luminance (brightness of surfaces) than to changes in chrominance (colors). Therefore, experiments were also performed to determine the relative ef-fects of pixelating the luminance alone and the chrominance alone. Pixelation was used, rather than straight downsampling, so that the distorted band(s) could be recombined with the other(s) without downsampling them.

Description of ExperimentsThere were three experiments to be performed in this laboratory assignment. These re-

quired the writing of two computer programs and the use of another supplied for the lab. The re-sults of the experiments were purely subjective since the experimenter was told to make judge-ments about the visual quality of the results.

Experiment 1

Find a sharp, clear 24-bit true-color image of size not smaller than 5122 pixels with plenty of distinct (not blurry) edges. Include a copy of the image in your report. Load this into Matlab (or a simple main program that you must write if you are using C) and downsample it us-ing your program. Determine the value of s (call it s) for which you begin to notice aliasing dis-tortion in the result. Therefore, run your routine with downsample factors of s = 2, 3, 4,…, dis-play the results of each, stop when you notice significant distortion, and let s = s. Save that par-ticular image to include in your report.

To perform this part of the experiment a program called downsample was written using Matlab. It simply inputs a multiband image and downsamples it by a factor of s through pixel copying. A listing of the program is given in the appendix. The experiment was run and a value of sn = 3 was determined.

Use your upsampling program on the images you created with your downsampling pro-gram (i.e., for s = 2, 3, 4,…, sn ). Display the results. Describe, as precisely as you can, the dif-ferences between these upsampled images and the original with which you started. Include in your report the image upsampled at s but not the others.

To perform this part of the experiment a program called upsample was written using Matlab. It inputs a multiband image and upsamples it by a factor of s through pixel replication. That is each pixel in the input image is replicated in an s s block in the output image. A listing of the program is given in the appendix.

Experiment 2

Split your true-color image into L, a, and b bands. If you are using Mat-lab, you can use the RGBtoLab.m function that I provided. Downsample L and upsample the result by s = 2, 3, 4,…, to create other L bands (call them Ls ). For each s, recombine Ls with a and b to form an new RGB image, ILs . If you are using Matlab, you can use the LabtoRGB.m function that I provided. Determine the value of s (call it sn ) for which you begin to notice aliasing dis-

Wan Ibrahim 2 8 September, 2013

Page 3: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

tortion in the result. Save that particular image to include in your report. Ex-plain the difference between what you have done in this section with that in experiment 1. Does the value of sn you found in this section differ from that which you found in experiment 1? Describe the differences in the appear-ances of the resultant down / up-sampled images in experiment and this section (the images that were downsampled then upsampled at their respec-tive values of sn.)

To perform this experiment LabtoRGB was used to split the image into L, a, and b bands. Both the upsample and the downsample program were used on the L band of the original image with successively larger factors. Each resultant Ls was recombined with the un-processed a and b bands.

Experiment 3

Repeat the previous experiment but downsample a and upsample the result by s = 2, 3, 4,…, to create other a bands (call them as) and do the same with b to create bands bs. For each s, recombine L with as and bs to form an new RGB image, Ias,bs . If you are using Matlab, you can use the LabtoRGB.m function that I provided. Determine the value of s (call it sn) for which you begin to notice aliasing distortion in the result. Save that particular image to include in your report. Explain the difference between what you have done in this section with that in experiment 1. Does the value of sn you found in this section differ from that which you found in experiment 1? Describe the differences in the appearances of the resultant down / up-sampled images in experiment and this section (the images that were downsampled then upsampled at their respec-tive values of sn.)

To perform this experiment LabtoRGB was used to split the image into L, a, and b bands. Both the upsample and the downsample program were used on the a and b bands of the original image with successively larger factors. Each resultant as and bs was recombined with the unprocessed L band.

Wan Ibrahim 3 8 September, 2013

Page 4: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Results of ExperimentsThe image that was used (Fig. 1) in the experiment was a 24-bit true-color image in .bmp format taken by the author in Central Park, New York City in July 1994.

Figure 1. Original Image

Wan Ibrahim 4 8 September, 2013

Page 5: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Experiment 1

Degradation was first noticeable at a downsample factor of 3. Extreme degradation oc-curred with a downsample factor of 5. (Fig. 2..)

Figure 2. Downsampled images: DS factor = 3 (left) DS factor = 5 (right)

Upsampling by a factor of 3 the image downsampled at DS factor = 3, the result is a pixe-lated or mosaic image. (Fig. 3.)

Figure 3. Image pixilated by a factor of 3.

The result of pixelation by a factor of 3 is an image that has nearly all the features of the original but has contours that are noticeably jagged.

Wan Ibrahim 5 8 September, 2013

Page 6: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Experiment 2

Like in experiment 1, degradation was first noticeable at a downsample factor of 3 (Fig. 4). The result of downsampling only the luminance band resulted in an image that was visually identical to the result of experiment 1 (Fig. 5). That is, those features that had long straight or smoothly varying boundaries (i.e., edges) in the original image appear jagged in the pixelated image.

Figure 4. Luminance pixelated by a factor of 3

Wan Ibrahim 6 8 September, 2013

Page 7: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Figure 5. Middle: original image. Left: image pixelated (all three bands) by a factor of 3. Right: Luminance (L* band) pixelated by a factor of 3 (a* and b* unchanged).

There is little if any discernable difference between the pixelation of all three bands and of the luminance alone.

Wan Ibrahim 7 8 September, 2013

Page 8: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Experiment 3

The results of this experiment show, quite clearly, that the human visual system is far less sensitive to the resolution of the color bands in an image than to the luminance band. For exam-ple (Fig. 6), consider a side by side comparison of the pixelating of luminance at a factor of 3 (a* and b* unchanged) with the a* and b* bands pixelated by a factor of 3 (L unchanged).

Figure 6. Left: L* pixelated by a factor of 3 with a* and b* unchanged. Right: a* and b* pixelated by a factor of 3 with L* unchanged.

Whereas the contours appear jagged in the luminance (L*) pixelated image, they appear smooth in the color (a* and b*) pixelated image.

Wan Ibrahim 8 8 September, 2013

Page 9: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

At pixelation factor 5, a side-by-side comparison with the original shows that the image has been distorted enough to see it. But it is not until a pixelation factor of about 10 that the im-age is, at first glance, seen as distorted (Fig. 7).

Figure 7. Middle: original image. Left: a* and b* pixelated by a factor of 5 (L* un-changed). Right: a* and b* pixelated by a factor of 10 (L* unchanged).

Wan Ibrahim 9 8 September, 2013

Page 10: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

The distortion appears as a smearing of the colors. Although we know that the distortion is a pixelation of the color, we do not see it in these images as blocks of color. It is not until a much higher pixelation factor that the blockiness of the color is visually apparent. In figure 8, the blockiness of the color is visually apparent as such.

Figure 8. Pixelation of the a* and b* bands by a factor of 16 (L* unchanged).

Wan Ibrahim 10 8 September, 2013

Page 11: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Discussion of ResultsExperiment 1 demonstrated that an image cannot be resized (smaller) significantly

through downsampling without introducing distortion. The distortion appears as a blockiness in smooth regions or a jagged quality in the image contours. Experiment 2 demonstrated that pixe-lating only the luminance band of an image has an effect very similar to that of pixelated all three bands. This suggests that the luminance band is the primary carrier of features in the image that are spatially localized. That is, lines or contours which are characterized by local brightness con-trast differences are perceived by the human visual system with a higher degree of resolution than pure color information. This idea was further supported by experiment 3 which demon-strated the relative insensitivity of the human visual system to color resolution. It is interesting to note that it was precisely this phenomenon that led to the development of NTSC color televi-sion.

ConclusionThese three experiments demonstrated the effects of downsampling and pixelation on

color images. It was seen that an image cannot be downsampled by a factor of more than 3 with-out visual distortion, primarily in the form of blockiness or jagged lines. It was also seen that this perceptual response to downsampling occurs mainly in the luminance processing part of the visual system. By separately pixelating the luminance band and the color bands, it was demon-strated that the perception of blockiness in the image appears when the luminance is pixelated by a factor greater than three. Moreover the result was nearly identical to the straight pixelation of all 3 bands of the image. Pixelation of the color bands had to be much more extreme to notice the distortions introduced by the process.

Wan Ibrahim 11 8 September, 2013

Page 12: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Appendix: Program ListingsThe computer programs to perform these experiments were Matlab scripts. Complete

listings of these programs follow:

Downsampling ProgramThis following was stored as an “m”-file called “downsample.m.”

----begin downsample.m----

% downsample an image, I, uniformly by a factor of s% where s is an integer%% K = downsample(I,s)

function K = downsample(I,s)

if s ~= fix(s)disp(‘the downsample factor, s, must be an integer.”return;

end

[R,C,d] = size(I); % dimensions of image IJ = zeros(floor(R/s),floor(C/s),d); % working image

J = I(1:s:R,1:s:C,:); % downsample I by factor s.

% output the image in the correct data type

if isa(I,'uint8') % the input was uint8 K = uint8(J); % make the output the sameelse % the input was a double K = J; % leave output as a doubleend

return;----end downsample.m----

Wan Ibrahim 12 8 September, 2013

Page 13: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Upsampling ProgramThis following was stored as an “m”-file called “upsample.m.”

----begin upsample.m----

% upsample an image, I, uniformly by a factor of s% where s is an integer%% K = upsample(I,s)

function K = upsample(I,s)

if s ~= fix(s)disp(‘the upsample factor, s, must be an integer.”return;

end

[Ri,Ci,d] = size(I); % dimensions of input image IR = Ri*s;C = Ci*s;J = zeros(R,C,d); % output image

for j=1:s % j = row offset + 1 r = floor((R-j)/s) + 1; % number of rows in T at this off-set for i=1:s % i = col offset + 1 c = floor((C-i)/s) + 1; % number of cols in T at this off-set J(j:s:R,i:s:C,:) = I(1:r,1:c,:); % copy T into J endend

% output J in the correct data type

if isa(I,'uint8') % the input was uint8 K = uint8(J); % make the output the sameelse % the input was a double K = J; % leave J as a doubleend

return;----end upsample.m----

Wan Ibrahim 13 8 September, 2013

Page 14: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

RGB to L*a*b*

This following was stored as an “m”-file called “RGBtoLAB.m.”

----begin RGBtoLAB.m----

% Convert a true-color image (RGB) to the L*a*b* color space.%% Input image I must be r x c x 3 in size.% Three r x c (2D) images, L, a, and b, are output.%% note: L is in [ 0.0000, 100.0397]% a is in [-137.8146, 96.1775] % b is in [-195.8561, 425.9210] %% such that: black is (L,a,b) = ( 0.0000, 0.0000, 0.0000)% white is (L,a,b) = (100.0397, 0.0000, 0.0000)% red is (L,a,b) = ( 61.5944, 91.5769, 425.9210)% yellow is (L,a,b) = ( 95.4512, -16.9773, 272.1970)% green is (L,a,b) = ( 81.1597, -137.8146, 89.7796)% cyan is (L,a,b) = ( 87.0812, -81.4112, -137.2479)% blue is (L,a,b) = ( 40.2654, 52.2266, -195.8561)% magenta is (L,a,b) = ( 70.4152, 96.1775, -21.9940)%% function [L,a,b] = RGBtoLab(I)

function [L,a,b] = RGBtoLab(I)

[r,c,d] = size(I);if ( d ~= 3 ) disp('RGBtoLab returned an error:'); disp('Image must be in true color format (r x c x 3).'); return;end

ID = double(I); % convert to double

m = min(min(min(ID))); % find the minimum intensityif m < 0 % if there are any negative values, ID = ID .* (ID > 0); % zero themend

M = max(max(max(ID))); % find the maximum intensityif (M > 1) & (M < 256) % then the probable max is 255 ID = ID / 255; % normalize to [0-1]elseif M > 255 % then image is not byte-sized ID = ID / M; % normalize to [0-1]end % if max <= 1, normalization is not required

% map RGB values to XYZ-spaceX = 0.607*ID(:,:,1) + 0.174*ID(:,:,2) + 0.201*ID(:,:,3);Y = 0.299*ID(:,:,1) + 0.587*ID(:,:,2) + 0.114*ID(:,:,3);Z = 0.000*ID(:,:,1) + 0.066*ID(:,:,2) + 1.117*ID(:,:,3);

Wan Ibrahim 14 8 September, 2013

Page 15: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

% compute the white point RGBtoXYZ = [ 0.607 0.174 0.201; 0.299 0.587 0.114; 0.000 0.066 1.117 ];W = RGBtoXYZ * [1 1 1]';X0 = W(1,1); % 0.982 Y0 = W(2,1); % 1.000 Z0 = W(3,1); % 1.183

% compute LabYsmall = Y < 0.01;Lsmall = Ysmall .* ((903.3 * Y / Y0) + 16);L = (25 * ( (100 * ((~Ysmall) .* Y) / Y0).^(1/3) )) - 16;L = L + Lsmall;a = 500 * ( ((X / X0).^(1/3)) - ((Y / Y0).^(1/3)) );b = 500 * ( ((X / X0).^(1/3)) - ((Z / Z0).^(1/3)) );

return;

----end RGBtoLAB.m----

Wan Ibrahim 15 8 September, 2013

Page 16: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

L*a*b* to RGBThis following was stored as an “m”-file called “LABtoRGB.m.”

----begin LABtoRGB.m----

% Convert a Lab image to an RGB true-color image%% The Lab image is represented by three separate arrays,% L, a, and b, of type double. Each array must be of the% same size, r x c.% The output image, I, is r x c x 3 and of type uint8.%% note: L is in [ 0.0000, 100.0397]% a is in [-137.8146, 91.5769] % b is in [-195.8561, 425.9210] %% then: black is (L,a,b) = ( 0.0000, 0.0000, 0.0000)% white is (L,a,b) = (100.0397, 0.0000, 0.0000)% red is (L,a,b) = ( 61.5944, 91.5769, 425.9210)% yellow is (L,a,b) = ( 95.4512, -16.9773, 272.1970)% green is (L,a,b) = ( 81.1597, -137.8146, 89.7796)% cyan is (L,a,b) = ( 87.0812, -81.4112, -137.2479)% blue is (L,a,b) = ( 40.2654, 52.2266, -195.8561)% magenta is (L,a,b) = ( 70.4152, 96.1775, -21.9940)%% function I = LabtoRGB(L,a,b)

function I = LabtoRGB(L,a,b)

[r,c,d] = size(L);

if ( ~((size(L) == size(a)) & (size(a) == size(b))) ) disp('LabtoRGB returned an error:'); disp('L, a, and b must have the same dimensions.'); return;end

% compute (Y/Y0).^(1/3)Lsmall = L < 9.033;Y13 = (~Lsmall) .* (L+16)/(25*(100^(1/3)));Y13 = Y13 + (Lsmall .* ((L/903.3).^(1/3)));

% compute (Z/Z0).^(1/3)Z13 = ((a - b)/500) + Y13;

% compute (X/X0).^(1/3)X13 = (b/500) + Z13;

Wan Ibrahim 16 8 September, 2013

Page 17: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

% compute the white point RGBtoXYZ = [ 0.607 0.174 0.201; 0.299 0.587 0.114; 0.000 0.066 1.117 ];W = RGBtoXYZ * [1 1 1]';X0 = W(1,1); % 0.982 Y0 = W(2,1); % 1.000 Z0 = W(3,1); % 1.183

% compute X, Y, and ZX = (X13.^3)*X0;Y = (Y13.^3)*Y0;Z = (Z13.^3)*Z0;

% make output imageI = zeros(r,c,3);

% map XYZ values to rgb-spaceI(:,:,1) = 1.910*X - 0.534*Y - 0.289*Z;I(:,:,2) = -0.984*X + 1.998*Y - 0.027*Z;I(:,:,3) = 0.058*X - 0.118*Y + 0.897*Z;

I = uint8(255 * I);

return;

----end LABtoRGB.m----

Wan Ibrahim 17 8 September, 2013

Page 18: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

Matlab Script Files

These files were used to run the experiments.

Experiment 1

% EECE 253 Image Processing Fall 2000% Laboratory Assignment 1% Downsampling Experiment 1

I=imread('CentralParkFlowers.bmp','bmp');for i=1:8 figure(i) image(downsample(I,i));end

% after finding that DS factor 3 is the first noticeablely dis-torted image:

J=downsample(I,3);imwrite(J,'CPF_DS_fctr_3.bmp','bmp');

K=downsample(I,5);imwrite(K,'CPF_DS_fctr_5.bmp','bmp');

K=upsample(J,3);imwrite(K,'CPF_pixelated_fctr_3.bmp','bmp');

Experiment 2

% EECE 253 Image Processing Fall 2000% Laboratory Assignment 1% Downsampling Experiment 2

I=imread('CentralParkFlowers.bmp','bmp');

[R C d] = size(I);

[L a b] = RGBtoLab(I); % convert to Lab

for i=1:8 figure(i) J = downsample(L,i); K = upsample(J,i); [KR KC] = size(K);

Wan Ibrahim 18 8 September, 2013

Page 19: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

if KR <= R % KR <= R if KC <= C % KR <= R AND KC <= C Ta = a(1:KR,1:KC); Tb = b(1:KR,1:KC); else % KR <= R AND KC > C K = K(1:KR,1:C); Ta = a(1:KR,1:C); Tb = b(1:KR,1:C); end else % KR > R if KC <= C % KR > R AND KC <= C K = K(1:R,1:KC); Ta = a(1:R,1:KC); Tb = b(1:R,1:KC); else % KR > R AND KC > C K = K(1:R,1:C); Ta = a(1:R,1:C); Tb = b(1:R,1:C); end end

T = LabtoRGB(K,Ta,Tb); image(T);end

% after finding that DS factor 3 is the first noticeably dis-torted image:

J = downsample(L,3);K = upsample(J,3); [KR KC] = size(K);if KR <= R % KR <= R if KC <= C % KR <= R AND KC <= C Ta = a(1:KR,1:KC); Tb = b(1:KR,1:KC); else % KR <= R AND KC > C K = K(1:KR,1:C); Ta = a(1:KR,1:C); Tb = b(1:KR,1:C); endelse % KR > R if KC <= C % KR > R AND KC <= C K = K(1:R,1:KC); Ta = a(1:R,1:KC); Tb = b(1:R,1:KC); else % KR > R AND KC > C

Wan Ibrahim 19 8 September, 2013

Page 20: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

K = K(1:R,1:C); Ta = a(1:R,1:C); Tb = b(1:R,1:C); endend T = LabtoRGB(K,Ta,Tb);imwrite(J,'CPF_L_DS_fctr_3.bmp','bmp');

Experiment 3

% EECE 253 Image Processing Fall 2000% Laboratory Assignment 1% Downsampling Experiment 3

I=imread('CentralParkFlowers.bmp','bmp');

[R C d] = size(I);

[L a b] = RGBtoLab(I); % convert to Lab

for i=3:10 figure(i) ad = downsample(a,i); au = upsample(ad,i); bd = downsample(b,i); bu = upsample(bd,i);

[KR KC] = size(au); if KR <= R % KR <= R if KC <= C % KR <= R AND KC <= C K = L(1:KR,1:KC); else % KR <= R AND KC > C K = L(1:KR,1:C); au = au(1:KR,1:C); bu = bu(1:KR,1:C); end else % KR > R if KC <= C % KR > R AND KC <= C K = L(1:R,1:KC); au = au(1:R,1:KC); bu = bu(1:R,1:KC); else % KR > R AND KC > C K = L(1:R,1:C); au = au(1:R,1:C); bu = bu(1:R,1:C); end

Wan Ibrahim 20 8 September, 2013

Page 21: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

end

T = LabtoRGB(K,au,bu); image(T);end

% after finding that DS factor 5 is the first noticeably dis-torted image:

ad = downsample(a,5);au = upsample(ad,5); bd = downsample(b,5);bu = upsample(bd,5);

[KR KC] = size(au);if KR <= R % KR <= R if KC <= C % KR <= R AND KC <= C K = L(1:KR,1:KC); else % KR <= R AND KC > C K = L(1:KR,1:C); au = au(1:KR,1:C); bu = bu(1:KR,1:C); endelse % KR > R if KC <= C % KR > R AND KC <= C K = L(1:R,1:KC); au = au(1:R,1:KC); bu = bu(1:R,1:KC); else % KR > R AND KC > C K = L(1:R,1:C); au = au(1:R,1:C); bu = bu(1:R,1:C); endend

T = LabtoRGB(K,au,bu);imwrite(J,'CPF_C_DS_fctr_05.bmp','bmp');

ad = downsample(a,10);au = upsample(ad,10); bd = downsample(b,10);bu = upsample(bd,10);

[KR KC] = size(au);if KR <= R % KR <= R if KC <= C % KR <= R AND KC <= C

Wan Ibrahim 21 8 September, 2013

Page 22: Image Processing Lab Report Sample

EECE 253 Image Processing Vanderbilt University Fall Semester 2013 School of Engineering

K = L(1:KR,1:KC); else % KR <= R AND KC > C K = L(1:KR,1:C); au = au(1:KR,1:C); bu = bu(1:KR,1:C); endelse % KR > R if KC <= C % KR > R AND KC <= C K = L(1:R,1:KC); au = au(1:R,1:KC); bu = bu(1:R,1:KC); else % KR > R AND KC > C K = L(1:R,1:C); au = au(1:R,1:C); bu = bu(1:R,1:C); endend

T = LabtoRGB(K,au,bu);imwrite(J,'CPF_C_DS_fctr_10.bmp','bmp');

Wan Ibrahim 22 8 September, 2013