Wednesday, June 26, 2013

Activity 6 : Enhancement by Histogram Manipulation

(Welcome, Interwebs traveler. A note before you go: please click any image to view in enlarged/theater mode. Now explore on!)

Well hello there!

I'm sorry that this blog post is currently empty, I'm still finishing up with this activity and am trying to figure out how to post about it. I'm having a bit of difficulty because of other requirements, and because I unfortunately don't find this activity as fun as the others :(

I'll post as soon as possible. Thank you and come back later. :)

Thursday, June 20, 2013

Activity 5 : Area Estimation of Images

(Welcome, Interwebs traveler. A note before you go: please click any image to view in enlarged/theater mode. Now explore on!)

This week, we are tasked to calculate the area of objects in images, particularly those objects with irregular shapes. Our main technique for computing the area is by using Green's theorem. To test the theorem, we first use the technique on synthetic images of regular shapes. Then, we will apply it to Google Maps images of real structures. Yay!


Green's Theorem

Theory


According to Wikipedia, Green's theorem gives the relationship between a line integral around a simple closed curve C (taken counterclockwise) and a double integral over the plane region D bounded by C [1]. This is expressed by the equation:

Figure 1. Green's theorem. The line integral around the simple closed curve C
is equal to the double integral over the plane region D bounded by C. Equation from [1].

where L and M are functions of (x, y) defined on an open region containing D, and with continuous partial derivatives at that region [1]. The above theorem can be used to calculate the area if we suppose that the term in the right-hand integral is equal to 1:

Figure 2. Assumption that the difference of the partial derivatives
of M (with respect to x) and L (with respect to y) is equal to 1. Equation from [1].

The right-hand side then becomes an expression of the area of the open region D. By the Green's theorem, this also means that the line integral on the left-hand side can be used to compute the area.

In images, we will be dealing with objects defined by pixels, which are commonly represented as discrete squares on a display device [2]. This means that the boundary of the region D of our image objects are defined by discrete points. We can then use the discrete version of the line integral in Green's theorem, provided by our AP186 Activity 5 handout [3]:

Figure 3. Discrete form of the area A, obtained from the line integral in Green's theorem [3].

Experimental Procedure


The Activity 5 handout explains that the discrete form of the area equation in Figure 3 can be used on closed curves with no concavities, such as the shape in Figure 4a [3]. This is done by dividing the shape into "pie slices", enclosing each slice by drawing a rectangle around it, and then subtracting excess triangles from that rectangle (as in Figure 4b).

The single pie slice has an area given by the equation below its figure. The summation of the area of each pie slice should result in the area of the whole object.

Figure 4. Visualization for computing the area of an object with no concavities.
a) left, the convex object divided into "pie slices"; b) right, one slice enclosed with a rectangle.

To implement Green's theorem on an object in an image, we first isolate the edge of this object by using the edge function on MATLAB. The edge function takes a grayscale image and returns a corresponding object that is value 1 (or white) where the function finds an edge and value 0 (or black) elsewhere [4].

Next, we extract the pixel coordinates of the edge using the find function, subtract the coordinates of the centroid of the shape (computed per axis by taking the sum of the pixel coordinates for that axis and dividing by the total number of pixels on the edge; further information here [5]), and sorting the resulting (x, y) coordinates in increasing angle theta (computed by taking the inverse tangent of y over x). The sorting allows us to use the discrete form of Green's theorem.


Area Calculation

Synthetic Images (Centered and Upright)


As promised, we'll first apply Green's theorem on regular images. The images Figure 5 are 256x256 pixels in size and were produced using MATLAB code. The desired dimensions were specified in the MATLAB code and resulted in these centered, upright white shapes on a black background.

Figure 5. Synthetic images produced for testing Green's theorem. The dimensions are, from left to right:
1st row: circles of radius 0.1, 0.3, 0.5 and 0.8 units;
2nd row: squares of side 0.2, 0.6, 1.0 and 1.6 units;
3rd row: triangles of base/height 0.2, 0.6, 1.0 and 1.6 units;
4th row: rectangles with 0.6 length & 0.2 width, 1.0 length & 0.6 width, 1.6 length & 1.0 width.

Since the shapes were created as specified in MATLAB, the area can be analytically computed using known area formula [6]. We also use the pixel-counting method for comparison, as the shapes are defined by pixels which may be considered as tiny squares with a set area; of course, we shouldn't forget to convert the number of pixels to area using the appropriate conversion factor. This conversion factor is known from the MATLAB code, since I set the 256 pixels per axis to represent 2 arbitrary units; thus, the factor is (2/256) ^2.

The table shown in Figure 6 provides the computed area for these shapes. The first column gives the name of the shape; the succeeding columns gives the relevant programmed dimensions and the calculated dimensions (done by manually determining the actual dimensions of the image in terms of pixels on GIMP); the last three columns give the area using known formula, pixel-counting and Green's theorem, in that order.

Figure 6. Summary table of the area of the synthetic images,
created with programmed dimensions in MATLAB.
The last three columns show the area computed
via known formula, pixel-counting and Green's theorem.

Using the area calculated using known formula as the theoretical area, the percent error of the area via pixel-counting and via Green's theorem is shown in Figures 7a to 7d.



Figure 7. Graph of the percent error of the area calculated
via Pixel-Counting and Green's Theorem, for the synthetic images of:
1st row: a) left, circle; b) right, triangle;
2nd row: c) left, square; d) right, rectangle.

Looking at the graphs, we can see that the area computed via pixel-counting is highly effective (with 0% error!) for squares and rectangles of any dimension. This is because the pixels are squares themselves, and squares/rectangles of any dimension are simply groups of many pixels. Thus, counting the total number of pixels produces an accurate value of the area of the squares/rectangles.

Pixel-counting has some error, though, for shapes such as circles and triangles. The square pixels are unable to reproduce the smooth edges of circles or triangles, as shown by the close-ups in Figure 8. This means that the area from pixel-counting may be smaller or larger than what we compute using known formula.

Figure 8. Close-ups of the jagged edges of synthetic shapes:
a) left, circle; b) right, triangle.

For the Green's theorem technique, the percent error apparently decreases with increasing shape dimensions (and consequently increasing shape area). This is noticeable in the decreasing bar lengths in the % error graphs, with the exception of the triangle where the image with base and height of 0.6 units produces a smaller % error than either of the triangles with base and height of 1.0 or 1.6 units. I'm not entirely sure what caused this, but it may have been due to the edge function which we'll explore in a bit.

For now, let's investigate other things...

Synthetic Images (Off-center and Upright)


The MATLAB code used for this activity involves searching for the centroid of the synthetic images. Since all of my synthetic images are created using MATLAB and set to be centered at the image center, most of the shapes (particularly the circles, squares and rectangles) had their centroids at the dead center of the image.

What happens if the shapes were not at the center of the image? I selected one dimension per shape and placed the image in different quadrants to produce off-center shapes. Will the calculated area be the same as the upright and centered shapes? Let's find out.

Figure 9 shows the off-center shapes (still produced using MATLAB). We have shapes in the 1st, 2nd, 3rd and 4th quadrants, and we'll label the quadrants as Q1, Q2, Q3 and Q4. For the circle, the radius r = 0.3 was chosen. For the square, the side length s = 0.6 was selected. For the triangle, both the base and the height were set at 0.6 units. For the rectangle, the length was programmed to be l = 0.6 and the width was w = 0.2 units.

Figure 9. Synthetic images shifted to off-center positions.
Shapes vary per row while positions vary per column.
Per row, in descending order: circle, square, triangle, and horizontal rectangle.
Per column, left to right: Q1, Q2, Q3 and Q4 quadrants.

The summary table in Figure 10 gives the area via known formula as well as the areas calculated via pixel-counting and Green's theorem, per quadrant position.

Figure 10. Summary table of the area of the synthetic images
displaced from center to different quadrants of the image space:
quadrants Q1, Q2, Q3 and Q4.

Graphing the % error per figure position resulting from using Green's theorem (noting that each position is expected to produce the same area value per shape), we can see in Figure 11 below that the square has has the lowest and most consistent % error of all shapes at almost 0% error for all positions. The circle follows as the next most consistent, having around 1% error for all positions.

Figure 11. Graph of the percent error of the area
calculated via Green's theorem per figure/shape position
on the image space.

The rectangle gives a surprising result, with the % error shooting up from almost 0% to 4% error. This is weird to me because the square and the rectangle should have similar results, considering that the rectangle is (in its essence) a few squares put together. The triangle is quite strange too, because it consistently has almost 0% error except for the image where the triangle is displaced to Q3. Here, the % error has shot up to around 2.5%.

I'm not entirely sure what has caused these errors, but my guess would be either something's wonky with my "displace-the-shape" code (which may resize the shape as well as displace it) or the edge function is again to blame. But we'll get to the edge later.

For now, we'll check one last thing...

Synthetic Images (Rotated)


For fun, I also wanted to see how the Green's theorem would perform if the images were to be rotated. Figure 12 shows the rotated shapes. I rotated the same square, triangle and rectangle in the Off-center and Upright section using Paint by angles of 22.5, 45.0 and 67.5 (counterclockwise), filling in the parts of the image background that would turn white due to the rotation. I didn't include the circle because I felt I might not be able to distinguish the difference upon rotation.

Figure 12. Synthetic images (originally centered) rotated counterclockwise.
Per column, left to right: 22.5, 45.0 and 67.5 degree rotations.

The summary table in Figure 13 gives the area via known formula as well as the areas calculated via pixel-counting and Green's theorem, per rotation.

Figure 13. Summary table of the area of the synthetic images
rotated by 22.5, 45.0 and 67.5 degrees.

Checking the % error once more, which is graphed in Figure 14 per angle of rotation, we can see that at 22.5 and 67.5 degree rotations, the % error of the square, triangle and rectangle are all clumped together at 0.1% to 0.2%. For the 45.0 degree rotation, the rectangle has 0% error. This is a bit odd for me, considering that the square has the highest % error at 0.9%, and I again expected both shapes to have similar results due to their similarity in structure. The triangle has a % error of 0.4%.

Figure 14. Graph of the percent error of the area
calculated via Green's theorem per figure/image rotation.

Of course, I was expecting to have some error since the rotation would produce slanted sides in the images, leading to the same problem of the jagged edges in Figure 8 above.

The next section of Area Calculation should be of the Google Maps images, but we'll pause at this point to venture into the effect of the MATLAB edge function.

Effect of the edge Function


The Mathworks Help website [7] tell us that there are six different algorithms to choose from when using the edge function: Sobel, Prewitt, Roberts, Laplacian of Gaussian (LoG), Zero-cross and Canny. Mathworks provides more information on each method, including the fact that the default edge algorithm is the Sobel method.

It should be noted that in the previous discussions above, I did not specify the method to use and therefore MATLAB resorted to the Sobel method. But for this section, we will explore the effect of each method on each shape.

Figures 15a to 15d show animated GIFs of the edge obtained for each method. Hopefully the animated GIFs will start up at the same time (so it doesn't give that much of a head ache), but each GIF may be clicked and viewed separately to see the particular edge effects.



Figure 15. Animated GIF images of the extracted shape edges
using the different edge algorithms: (in order of appearance)
Sobel, Prewitt, Laplacian of Gaussian, Zero-cross, Roberts and Canny.

The shapes I used were still those used in the Off-center and Upright section above, but zoomed and cropped for easy viewing. The shapes were all zoomed and cropped in exactly the same way, so the deviations in the shape's edge are all caused by the edge algorithms.

The deviations in the circle edge are a bit difficult to characterize, mainly because they all produce a jagged edge outline that resembles the original circle. However, if we view the GIF as the edge algorithm changes, we can see that there are slight differences in each. Visually, the LoG and Zero-cross methods appear to produce the most symmetric edge outline, so for me I'd use these two for circles next time.

The edge algorithms are less merciful on the triangle. As the GIF changes, we can see that all algorithms except for the Roberts method add extra pixels on its corners while the Roberts method (although nearly perfect in shape) removes some pixels from one corner. From this, I guess the least worse method would be the Roberts method.

We can see that the effect on the square and the rectangle are the same, namely: the Sobel and Prewitt methods remove some pixels from the edge of the shape while retaining the boxy figure; the LoG and Zero-cross methods add extra pixels to the corners; the Roberts method retains the perfect shape; and, Canny rounds out the edges of the boxy shapes. From this, we now know that we should have used the Roberts method for the square and the rectangle.

Now that we're equipped with this knowledge, we continue with our Area Calculation and have fun with Google Maps! :D

Area Calculation (continuation)

Google Maps Fun Time


To test what we've learned, we apply our image-area-calculating skills on the Google Maps images of the largest swimming pool in the world... the San Alfonso del Mar [8]! According to Guinness world records [9], San Alfonso del Mar in Chile is the largest swimming pool (by area) in the world, having an area of 80,000 square meters. That's gigantic!

Figure 16. Screenshot taken of the Google Maps satellite image
of the San Alfonso del Mar swimming pool in Chile.

Figure 16 is the Google Maps image of San Alfonso del Mar. We extract the shape of the pool and show it as a white shape on a black background for processing in MATLAB. Since the Roberts method appears to produce the most perfect edge outline for most shapes, we use it on San Alfonso with Green's theorem and get a calculated area of 67,782 square meters. This comes at a % error of 15.3%. Not bad, considering we weren't actually in Chile to measure the pool.

But let's put the size of the pool into perspective. We take an outdoor Olympic-size pool like the one in McCarren Park [10]. It claims it's an Olympic-size pool, though from its shape I think it's a pool with Olympic-size lap lanes with extensions for wading.

Figure 17. Screenshot taken of the Google Maps satellite image
of the McCarren Park pool in the USA.

The website [10] states that it is 37,950 square feet or 3525.6704 square meters in area. We confirm this size using our image-area-calculation skills, using the Roberts edge method and Green's theorem, and get a calculated area of 2,289.9 square meters with a % error of 35.1%. It's a bit less tolerable; however, we should note that there are people and other objects in the satellite image that affect the shape we obtain.

In any case, theoretically (using their respective claimed area values) there are 22.69 McCarren Park pools and by our Green's theorem calculations there are 29.60 McCarren Park pools in the San Alfonso del Mar. Either way, that's a pretty huge pool, and I hope someday I can come swim (or maybe boat!) in it. :D

Grading

Based on the criteria for self-grading, I give myself a 12/10 for completing the activity, investigating different aspects within the activity and having a nicely formatted blog post. :)

Tuesday, June 18, 2013

Activity 4 : Image Types and Formats

(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:
  • 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.

Basic Image Types

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:
a) left, the continents from [1]; b) middle, grains from [2]; c) right, fractal image from [3].

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. :)