(Welcome, Interwebs traveler. A note before you go: please click any image to view in enlarged/theater mode. Now explore on!)
The activity today was meant to introduce us to the following:
The activity today was meant to introduce us to the following:
- basic image types;
- advanced image types;
- image file formats;
- image properties (such as resolution); and,
- image file operations on Scilab (or MATLAB).
Again, instead of working on Scilab I shall be working on MATLAB as in Activity 3.
We were tasked to search for examples of the four basic image types: binary images, grayscale images, truecolor images, and indexed images.
Binary Images
The Internet is a wonderful source for wonderful things. The three binary images in Figures 1a to 1c (scaled to 120px by 120px for display here) can be found on the Internet, from sources [1], [2] and [3], respectively. Checking the pixel values of the images using MATLAB shows that the pixels are of value 0 (black) or 255 (or 1, when properly scaled; white).
Figure 1: Binary images from the Internet:
The properties of the three images are found in Figure 2. The images have different image sizes (with Fig 1b as the smallest, Fig 1c as the biggest), different bit depths (value 8 for Fig 1a and Fig 1c, and value 24 for Fig 1b), and different file types (GIF and PNG). Because of this, the file sizes vary; however, they stay below 10 KB.
| Figure 2. Properties of the binary images in Figures 1a to 1c. |
Grayscale Images
The grayscale images below in Figures 3a to 3c (scaled to 120px by 120px for display here) also come from the Internet, all from [4]. According to MATLAB, the values in Figs 3a to 3c range from 32 to 121. This means that there are no pixels that are black (value 0) or white (value 255), and the images are in tones of gray.
Figure 3. Grayscale images from the Internet from [4]:
a) left, clock on a desk; b) middle, aerial shot; c) right, moon surface.
The properties of these images are in Figure 4 below. All of the images are 256px by 256px TIFF images, 64.1 KB in file size, with 96dpi resolution and a bit depth of 8.
| Figure 4. Properties of the grayscale images in Figures 3a to 3c. |
True-color Images
The true-color images here are from my own collection; in fact, they are of my beautiful daughter Jaiden on her first day of pre-nursery. :) The images were taken using a Canon EOS 1100D.
| Figure 5a. Truecolor image from my personal collection of Jaiden riding a plastic rocking toy. |
| Figure 5b. Truecolor image from my personal collection of Jaiden showing her Lego creation for the camera. |
| Figure 5c. Truecolor image from my personal collection of Jaiden comparing stamps with a classmate. |
The properties are found in Figure 6 below.
| Figure 6. Properties of the true-color images in Figures 5a to 5c. |
Indexed Images
According to Mathworks, indexed images are different from true-color images in that indexed images have numerical value data that correspond to colors in its color map, while true-color ones have RGB triple value data that define the colors directly (or explicitly) and have no need for a color map to interpret the colors.
Figure 7 (also from Mathworks) compares the indexed color data to the left with a true-color version of this data to the right. It can easily be seen that the indexed image appears to have discrete color changes while the true-color image has a smooth and continuous color change.
![]() |
| Figure 7. Comparison of indexed color data (on the left) and true-color data (on the right), taken from Mathworks [5]. |
Advanced Image Types
High Dynamic Range Images
Samples of high dynamic range (or HDR) images are displayed in Figures 8a to 8c, all taken from source [6]. The image have a surreal feel to them (despite being real scenes taken with a camera and not Photoshop creations), mainly because of the combination of colors highlighted in the images. Figure 9 gives the properties of these HDR images.
![]() |
| Figure 8a. HDR image of fireworks over a lake, taken from source [6]. |
![]() |
| Figure 8b. HDR image of a Christmas scene, taken from source [6]. |
![]() |
| Figure 8c. HDR image of city buildings, taken from source [6]. |
![]() |
| Figure 9. Properties of the HDR images in Figures 8a to 8c. |
Multispectral / Hyperspectral Images
These cool-sounding images take color to a whole new level. While true-color images capture only three channels of color (one each for red, green and blue), multispectral and hyperspectral images capture light information of many frequencies across the electromagnetic spectrum [7,8]. According to our AP186 handout, the multispectral images have channels in the order of 10's and the hyperspectral ones have channels in the 100's.
This allows for high-definition images such as these multispectral satellite images from the Netherlands-based Geospatial Data Service Center (source [9]), and these hyperspectral SpecTIR images (from source [10]). Sadly, I cannot --though I did attempt-- to download their images to examine the properties of the images. In any case, I suspect the file sizes of these images are gigantic!
3D Images
These bad boys also step it up from traditional images. Besides the conventional length and width information, we now get depth information from three-dimensional (3D) images. An example would be MRI scans, which becomes 3D thanks to the stacking of two-dimensional (2D) images of several cross-sections successively imaged. Figure 10 features several MRI scans with the corresponding 2D images that were used to make up the 3D image, taken from [11]. The actual 3D image is not available on the website.
![]() |
| Figure 10. Illustration showing the 2D images that makes up the 3D image (an MRI scan) on the rightmost side, taken from [11]. |
Videos
Temporal images or videos are awesome innovations which allow us to have TV shows and movies. One great video-hosting website is the ever-popular YouTube, and one funny/awesome video is one by Ryan Higa, teaching you how to sing like your favorite artists.
Checking the download file size of this video with keepvid.com, we can see that the file size depends on the desired file type and resolution of the video. For example, if we would want to obtain an 720p (or 1280x720 resolution) MP4 copy of this video, it would have an estimated 71.1 MB in file size.
| Figure 11. Download file sizes of the above video posted by Ryan Higa on YouTube [12]. |
Image File Formats
We'll discuss five formats for this post, some of which you may be familiar with: TIFF, GIF, BMP, JPEG and PNG. Figure 12 is a summary table containing information about these file formats, compiled from sources [13-21]. They are ordered in terms of the year they were introduced, with TIFF being the oldest (introduced in 1986!) and PNG being the youngest (celebrating its 17th year of existence since 1996).
| Figure 12. Summary table of the file formats TIFF, GIF, BMP, JPEG and PNG. |
While I'm not going to be showing sample images for each format (this post is already way too long and still getting longer >.<, and the images are easily available on the Internet :D ), I will be discussing them a little.
First up, TIFF or Tagged Image File Format. According to source [13], TIFF was created by Aldus Corporation in 1986 in an attempt to standardize the file format used by desktop scanners of different vendors, instead of letting them confusing us all by having their own proprietary formats. Initially, TIFF was a binary file format (to match the capability of scanners back then) but eventually it evolved to handle high color-depth images to contend with its younger counterparts JPEG and PNG. The compression scheme for TIFF images is flexible, depending on the compression tag used. Check source [13.1] for a table on this. Due to its capabilities and flexibility, TIFF is commonly used for image-manipulation applications as well as scanning, faxing and word processing. No weak points were found (not by me at least), so they were not listed in Figure 12. [13]
Next we have GIF. GIF was rolled out a year after TIF (in 1987) by CompuServe as a color image format to replace their previous black-and-white only run-length encoding (RLE) format [14]. Its lossless compression scheme was based on the LZW algorithm [15], which was initially a publicly available algorithm (more on that and PNG later). This enabled GIF to show sharp-contrast edges, sprite data and even small animations. However, GIF is limited to 256 colors within the 24-bit RGB color space and is thus unsuitable for digital photography. [14]
BMP was introduced by Microsoft in 1990 along with their Windows 3.0 operating system [16]. It was intended for use between applications within one Windows device or from one device to another [17] and is thus used for icons, screenshots and such within the Windows operating system. While BMP is sometimes used on the Internet, it was not designed to be portable. [17]
JPEG is the only truly lossy image format of the five we discuss here. Released in 1992 by the Joint Photographic Experts Group, it is commonly used for digital photography due to its ability to maintain smooth variations in tone and color [18]. However, its compression scheme is based on the discrete cosine transform (DCT) which is a mathematical operation that discards high-frequency information [18.1]. This reduction of information is called quantization, and this process in JPEG image storage leads to artifacts especially in regions with sharp-contrast. Thus, JPEG is not suited for use with line art or icon graphics. [18]
The youngest of the five is PNG, which is currently my favorite image format... mainly because of its history. Made available in 1996, the PNG file format was created by a group of graphics and compression experts who came together to provide a better, smaller (and most importantly FREE) alternative to GIF [19]. The story goes with the authors of the LZW seeking (and obtaining) a patent for their algorithm. With patent in hand, Unisys (the LZW authors) began to ask for royalties from all applications making use of the LZW algorithm... basically any application that can save to the GIF format. Of course, this sparked protest from the Internet community and prompted Thomas Boutell to find a team and come up with a new file format. It was named PING or PNG in jest, standing for PING Is Not GIF. [19] (Yeah, PNG group, stick it to the man!)
Anyway, since PNG was used as a royalty-free replacement to the GIF format, it uses a compression algorithm called DEFLATE [20]. It performs well against other file formats [21.1], and can be used for digital photography, and text or line art. However, it does not support non-RGB color spaces (like the CMYK) and thus cannot be used for professional-quality print graphics. [21]
Converting Images
Image Type
For this type of conversion, we'll use the picture of Jaiden in Figure 5c, since it's from my personal collection and it features red, green and blue colors. GIMP helped me to convert this true-color image into the following image types: binary, grayscale, and indexed. These are featured in Figure 13a to 13c.
Figure 13. Converted images from the true-color image in Figure 5c:
a) left, binary image; b) middle, grayscale image; c) right, indexed image.
For the binary image in Figure 13a, I made use of Image > Mode > Indexed... and selected the "Use black and white (1-bit) palette" option, removing unused colors from the color map. It can be seen that the darker shades (the dark red of the classmate's shirt, the shadows on the blackboard, the jean pants of those present) are all represented as black (or 0 value) while the lighter shades (the bright red of the teacher's shirt, the light blue of another classmate's shirt, the yellow-brown plastic chairs) are all represented as white (or 1 value) in the image.
For the grayscale image in Figure 13b, I used the Image > Mode > Grayscale option. Variations in the intensity of light can be seen as variations in the hues of gray presented in the image. Of course, if we hadn't seen the original true-color image and only had this grayscale image as reference, it would be difficult to determine the colors in the image by visual inspection.
For the indexed image in Figure 13c, I selected the Image > Mode > Indexed... > "Use web-optimized palette" option (also removing unused colors) to transform Fig 5c into this. From afar, the loss in color information is not strikingly obvious; however, close inspection will tell us that the colors lost their natural continuous variation.
An inspection of these image's properties tell us that only the bit depth and the file size have changed, particularly:
Bit depth - original was 24
- Fig 12b reduced from 24 to 8;
- Figs 12a and 12c remained at 24.
File size - original was 4.43 MB
- Fig 12a reduced to 1.94 MB;
- Fig 12b reduced to 3.22 MB; and,
- Fig 12c reduced to 4.36MB.
Image Format
Now we convert the Figure 5c (which is originally a JPEG image) to the different file formats. Figures 14a to 14d show this image as GIF, BMP, TIF and PNG images.
All these images were converted using File > Export on GIMP. During the exporting process, GIMP prompted me for additional settings, which I set as follows:
- GIF (Fig 13a): no Interlacing;
- BMP (Fig 13b): 24-bit (R8 G8 B8);
- TIF (Fig 13c): no Compression; and
- PNG (Fig 13d): saved Resolution, 0 Compression level.
Inspecting the file properties, again only the bit depth and the file size changed:
Bit depth - original was 24
- Fig 13a reduced from 24 to 8;
- Figs 13b to 13d remained at 24.
File size - original was 4.43 MB
- Fig 13a reduced to 3.37 MB;
- Figs 13b to 13d increased to 34.8 MB.
The reduced bit depth and file size are apparent in Figure 14a, since some loss in color information can be seen. Figures 14b to 14d are visually identical to Figure 5c, probably because the information is better stored (as evidenced by the large increase in file size).
| Figure 14a. Converted GIF image of Figure 5c, no Interlacing. File size reduced from 4.43 MB to 3.46 MB. |
| Figure 14b. Converted BMP image of Figure 5c, 24-bit (R8 G8 B8). File size increased from 4.43 MB to 34.8 MB. |
| Figure 14c. Converted TIF image of Figure 5c, no Compression. File size increased from 4.43 MB to 34.8 MB. |
| Figure 14d. Converted PNG image of Figure 5c, saved Resolution and 0 Compression level. File size increased from 4.43 MB to 34.8 MB. |
Scilab File Operations
Since I have been using MATLAB for my work, I'll investigate both the Scilab file operations as well as the corresponding MATLAB commands. Figure 15 summarizes these commands.
The Scilab commands were found in the Scilab Image Processing toolbox website [22] and the Scilab.org website [23], while the MATLAB commands are from the Mathworks help website [24].
![]() |
| Figure 15. Table of Scilab and MATLAB file operations. |
The Scilab and MATLAB commands have similar syntax and structure, with the exception of gray_imread (Scilab) and rgb2gray (MATLAB). As far as my searching has gone, to import an image as a grayscale in MATLAB you would have to first make use of imwrite to import the photo and then convert it to grayscale using rgb2gray.
Anyway, this table of Scilab and MATLAB commands will be helpful in future activities. Yay!
Grading
In terms of the provided grading criteria, I believe I deserve a 10/10 because I was able to complete the activity and have properly labelled images on a presentable blog post. :)










No comments:
Post a Comment