lab1_solution

# lab1_solution - RUTGERS UNIVERSITY School of Electrical and...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: RUTGERS UNIVERSITY School of Electrical and Computer Engineering ECE447 Fall Course Laboratory No. 1 – Solution Image Processing in MATLAB – Processing of Color Images 1 Preliminaries You can access MATLAB toolkits from either the departmental computers in CoRE Room 548 or from any computer with both Matlab and the Image Processing Toolbox. The image files referenced in this lab can be accessed from the course website at: cronos.rutgers.edu/~lrr/ If you are a new Matlab user, try running the built-in demos. Just type demos at the Matlab prompt. 2 Exercise 1 – Color Image Creation To begin you are requested to create three 3 × 3 ”images” having only 0 and 1 as elements. These images will be the red, green, and blue component images of a 3 × 3 color image that you will display. The color image should look like this: cyan white white green black yellow red magenta blue Figure 1: Desired 3 × 3 image. For example, the red image could be created by the statement >> r=[0,1,0;0,1,1;0,1,1]; 1 (a) After you have created the g and b images, use the Matlab statements >> rgb_image=cat(3,r,g,b); >> imshow(rgb_image); to display the image. Look at the image carefully to confirm that you have placed the saturated primary colors RGB and CMY in the correct places. Print the values of the three images by using the Matlab command >> [r,g,b] The resulting image plot is rather small (3 x 3 pixels). Use the magnification feature of the imshow command to scale the color image to a larger size for viewing. Report: Give the Matlab statements used to generate the green and blue images. Also include the scaled image plot to show that you have the correct component arrays (b) Now use the Matlab statement >> [X,map]=rgb2ind(rgb_image); >> figure(2); >> imshow(X,map); to convert to an indexed image representation, open a new image display window, and display that representation. Compare the two displays. They should be the same. (c) Now use the Matlab statement >> map to print the color map that was generated by the function rgb2ind . Using this printout and the values of the indexed image X verify that you understand how the colors are represented in the indexed image. (d) Finally, scale each of the images by a constant that is less than one and display it; e.g., scaling by 0.8 is implemented as: >> c=0.8; >> rgb_scaled=cat(3,r*c,g*c,b*c); >> imshow(rgb_scaled) Use values of c = 0.8, 0.6, 0.4, 0.2 to observe the effect. Report: What happens to the colors as c is varied over the range of values? *************************************************************************** SOLUTION (a) The Matlab code that generates the rgb components for and displays the requested color image (to full magnification) is: 2 % yellow=red+green % magenta=red+blue % cyan=green+blue r=[0 1 0;0 1 1;0 1 1]; g=[0 0 0;1 1 0;1 1 1]; b=[0 0 1;0 0 1;1 1 1]; rgb_image=cat(3,r,g,b); imshow(rgb_image,’InitialMagnification’,’fit’); [r,g,b] The resulting full magnification image is shown in Figure 2:...
View Full Document

{[ snackBarMessage ]}

### Page1 / 11

lab1_solution - RUTGERS UNIVERSITY School of Electrical and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online