Functions > Image Processing > Image Color Tools > Example: Tools for Packed Matrices
  
Example: Tools for Packed Matrices
Use the extract, replace, augment, and subcolor functions to extract or insert a single component matrix from a packed matrix comprising a color image, to pack three color components together, and to selected subsets of packed color matrices.
For information on using this example, refer to About Image Processing Examples.
extract
1. Read in a packed-color RGB color matrix.
Click to copy this expression
Click to copy this expression
(strike_rgb.bmp)
2. Extract the red component of the image using the extract function.
Click to copy this expression
3. Convert the matrix to an RGB image by supplying zero values for the blue and green components.
Click to copy this expression
Click to copy this expression
Click to copy this expression
(strike_red1.bmp)
replace
Manipulate and reassemble individual colors in an image.
1. Define a new variable that reduces the intensity of the red component in the sample image by half.
Click to copy this expression
2. Apply the replace function to the image.
Click to copy this expression
Click to copy this expression
(strike_new.bmp)
Click to copy this expression
Click to copy this expression
The red component of image matrix M has been completely replaced by newred. You can replace any matrix, red (1), green (2), or blue (3) using this method.
augment and subcolor
Use the augment function to combine three matrices, for example representing red, green, and blue, into one color matrix. It can be used for RGB, HLS, HSV, YIQ, and YCbCr images.
Use the subcolor function to extract a subset color matrix (RGB, HLS, etc.) by taking the proper submatrix from each of the three color sections of the combined matrix.
1. Create an HSV image by combining separate H, S, and V parts using augment.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
To view the wheel, we must first convert it from HSV to RGB.
Click to copy this expression
Click to copy this expression
2. Select a subset of the image using subcolor.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. View the whole image and its subset.
(wheel.bmp)
(wheel_sub1.bmp)