A MATLAB function creation

Create and Implement a function named rgb26cc() in MATLAB to convert any given RGB color image to corresponding 6-bit color coded image. The function will take an RGB color image as its input. The function should convert RGB values of each pixel in the input to the corresponding 6-bit color code.

Questions

  1. Create a MATLAB function named rgb26cc(), which takes one input parameter:

(1) imRGB (an RGB color image)
The rgb26cc() function should return a 6-bit color coded image matrix named im6CC with the same height and width

of the original RGB color image.

Implement RGB to 6-bit color code conversion according to the procedure introduced in the class. Please notice that the procedure converts only one pixel at a time, and thus, you must do one of the following ways for converting the entire image.
Intuitive Version
Create a nested loop to read RGB values for each pixel in imRGB and convert the RGB values to corresponding 6-bit color code. Create a new matrix of the same height and width and write the 6-bit color code to the corresponding location in the new matrix im6CC. The intuitive version is easy to understand but will be extremely slow when processing a large image.
High-Performance Version
Handle the conversion using matrix operation, which do not need a nested loop to process individual pixel. The high-performance version can convert the entire image with few statements. You will need to have comprehensive understanding to develop the algorithm. You will earn extra bonus points toward your semester grade if you implement the rgb26cc() function using high-performance version.
In addition, you need to create a MATLAB script named hw10.m to demonstrate the usage of the rgb62cc () function. In particular, in the script you need to
Read the color image provided (Hanfu_Libra.jpeg) and store pixel values in a variable (imC)
Call rgb26cc() to convert RGB color image stored in imC to corresponding 6-bit color coded image as imG.
Display the original color image and 6-bit color coded image side-by-side in a Figure Window where the original color image is shown on the left and the 6-bit color coded image is shown in the right. (Please notice that when display 6-bit color coded image using imshow() you should see a dark image due to the fact that the intensity range of the 6-bit color code is from 0 to 63. To better visualize a 6-bit color coded image, you can look up the imshow() function in MATLAB help file to specify the display range.)

Sample Solution

ACED ESSAYS