Functions > Image Processing > Example: Understanding the Packed Image Matrices
  
Example: Understanding the Packed Image Matrices
The value of a single RGB pixel is represented by a 24-bit binary number comprised of 8-bits for Red, 8-bits for Green and 8-bits for Blue. You can treat this 24-bit binary number as a 6-digit hexadecimal number where the two most significant, the middle two, and the least significant two digits represent the red, green and blue intensities, respectively. A black pixel is represented by a hex value of 0x000000 whereas a white pixel is represented by a hex value of 0xFFFFFF. Intermediate hex values produce one of ~16.8 million possible colors.
1. Define a matrix zoom factor.
Click to copy this expression
2. Define a zero matrix and use the zoom function to zoom it.
Click to copy this expression
Click to copy this expression
3. Define three identical matrices corresponding to the RGB color components of a packed image matrix.
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
4. Use the augment function to create a packed image matrix.
Click to copy this expression
5. Use the WRITERGB function to write the matrix to an external file.
Click to copy this expression
6. On the Math tab, click Image, browse for the written image file rgb1.bmp, and insert it in the worksheet.
The image shows a white square inside a black border. The color white results from the combined effect of the three component intensities R=255, G=255, and B=255 within the packed image matrix. Each pixel within the white square has a hex value of 0xFFFFFF.
7. Create a new packed image matrix made up of R, G/2 and B/4.
Click to copy this expression
8. Write the matrix to an external file.
Click to copy this expression
9. Click Image, browse for the written image file rgb2.bmp, and insert it in the worksheet.
The image shows an orange square inside a black border. The color orange results from the combined effect of the three component intensities R=255, G=128, and B=64 within the packed image matrix. Each pixel within the orange square has a hex value of 0xFF8040.
10. Create a new packed image matrix made up of R and no G or B.
Click to copy this expression
11. Write the matrix to an external file.
Click to copy this expression
12. Click Image, browse for the written image file red.bmp, and insert it in the worksheet.
The image shows a red square inside a black border. The color red results from the combined effect of the three component intensities R=255, G=0, and B=0 within the packed image matrix. Each pixel within the red square has a hex value of 0xFF0000.
13. Create a new packed image matrix made up of no R, G and no B.
Click to copy this expression
14. Write the matrix to an external file.
Click to copy this expression
15. Click Image, browse for the written image file grn.bmp, and insert it in the worksheet.
The image shows a green square inside a black border. The color green results from the combined effect of the three component intensities R=0, G=255, and B=0 within the packed image matrix. Each pixel within the green square has a hex value of 0x00FF00.
16. Create a new packed image matrix made up of no R, no G and B.
Click to copy this expression
17. Write the matrix to an external file.
Click to copy this expression
18. Click Image, browse for the written image file blu.bmp, and insert it in the worksheet.
The image shows a blue square inside a black border. The color blue results from the combined effect of the three component intensities R=0, G=0, and B=255 within the packed image matrix. Each pixel within the blue square has a hex value of 0x0000FF.