Top Banner
DIGITAL IMAGE PROCESSING ASSIGNMENT 6 RAJESH VENKATESANK00344 547
6
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Assignment 6

DIGITAL IMAGE PROCESSING

ASSIGNMENT 6

RAJESH VENKATESANK00344547

Page 2: Assignment 6

1. Web-Safe Colors

In order to complete this project, it is necessary that you find a program capable of generating the RGB component images for a given tif color image. For example, MATLAB's Image Processing Toolbox can do this, but you can also do it with image editing programs like Adobe's Photo-Shop or Corel's PhotoPaint. It is acceptable for the purposes of this project to convert an image to RGB (and back) manually.

(a) Write a computer program that converts an arbitrary RGB color image to a web-safe RGB image (see Fig. 6.10 for a definition of web-safe colors).

Solution:- MATLAB CODE:-

p = 1; q = 2; WHITE_COMP = 255;Img = imread('Fig0637.tif', 'tif');figure(1); subplot(p, q, 1); imshow(Img); title('orignal figure');colorValues = (0:0.2:1).'; webSafeMap = [repmat(colorValues,36,1) kron(colorValues,ones(36,1)) repmat(kron(colorValues,ones(6,1)),6,1)]; TmpImg = Img;ImgIndx = dither(TmpImg, webSafeMap);figure(2); imshow(ImgIndx);ImgIndx = double(ImgIndx) + 1; ImgIndx = max(1, min(ImgIndx, size(webSafeMap, 1))); r_clr = zeros(size(ImgIndx)); r_clr(:) = webSafeMap(ImgIndx, 1);g_clr = zeros(size(ImgIndx)); g_clr(:) = webSafeMap(ImgIndx, 2);b_clr = zeros(size(ImgIndx)); b_clr(:) = webSafeMap(ImgIndx, 3); ImgWebSafe = zeros(size(Img));ImgWebSafe(:, :, 1) = r_clr;ImgWebSafe(:, :, 2) = g_clr;ImgWebSafe(:, :, 3) = b_clr; subplot(p, q, 2); imshow(ImgWebSafe);title('websafeimage');

Page 3: Assignment 6

Original Image : - WEB SAFE IMAGE:-

CODE : -

Page 4: Assignment 6

(b) Download the image in Fig. 6.8 from the book web site and convert it to a web-safe RGB color image

SOLUTION: - MATLAB CODE

p = 1; q = 2;

Img = imread('Fig0608.tif', 'tif');

figure(1);

subplot(p, q, 1);

imshow(Img);

title('Original Image');

colorValues = (0:0.2:1).';

webSafeMap = [repmat(colorValues,36,1) ...

kron(colorValues,ones(36,1)) ...

repmat(kron(colorValues,ones(6,1)),6,1)];

WebSafeImg = ind2rgb(rgb2ind(Img, webSafeMap), webSafeMap);

subplot(p, q, 2);

imshow(WebSafeImg);

title('Web Safe Image');

imwrite(WebSafeImg, 'Fig0608_WebSafe.tif', 'tif');

Page 5: Assignment 6

CODE: -

OUTPUT: -

Page 6: Assignment 6