Image Types and Formats

The rapidly digitalizing world catapulted the exponential surge of photographs and images available to mankind.  These images come in different types and formats, i.e. no monopoly.  Basic image types include binary, grayscale, true color and indexed images.  Common image file formats are JPEG, TIF, PNG, and GIF.  In this activity, examples of the different image types listed would be given with specifications derived from GIMP and Scilab.  Also, the different image file formats will be discussed.  Lastly, image manipulation/conversion/transformation 🙂 will be done to some images.

Basic Image Types

Binary Image

Black OR white image. This type of image, however, crude-looking they are (as compared to the other flamboyant types), is used in many applications since, obviously, they are the easiest and the simplest to process.  However, its usage is limited by its impoverished representation of image information.  But if all the useful information can be provided by just the silhouette of the object, and that silhouette can be easily obtained, then it can be absolutely useful. Some common applications include; identifying objects on a conveyor (e.g. sorting chocolates), identifying object orientation, and on interpreting text [1].  Shown below is the Linux’ penguin in binary image type.

Figure 1. Binary Image

GIMP Image Properties

Pixel Dimension:         127 x 150 pixels

Print size:        44.80 x 52.92 millimeters

Resolution:      72 x 72 ppi

Color space:    RGB color

File Name:       C:\Users\R…binary.jpeg

File size:          3.8 KB

File Type:        JPEG Image

Size in memory:                      206.6 KB

Number of pixels:       19050

Source:            http://izaak.jellinek.com/tuxes/

Scilab Commands

–>imread(‘C:\Users\RnR-\Documents\Rob\Images\Binary image.jpg’);

Size:   150 rows X 127 columns

Truecolor Image

–>size(I)

ans  =

150.    127.    3.

–>imfinfo(‘C:\Users\RnR-\Documents\Rob\Images\Binary image.jpg’,’verbose’);

FileName: C:\Users\RnR-\Documents\Rob\Images\Binary image.jpg

FileSize: 3891

Format: JPEG

Width: 127

Height: 150

Depth: 8

StorageType: truecolor

NumberOfColors: 0

ResolutionUnit: centimeter

XResolution: 72.000000

YResolution: 72.000000

Grayscale Image

Black and white image.  Images in this type are in shades of gray.  One major reason in using grayscale image is that less information is needed for each pixel.  In fact, ‘gray’ is pone in which red, green, and blue components all have equal intensity in RGB space, and so it is only necessary to specify single intensity value for each pixel.  Grayscale images are very common since much of today’s display and image capture hardware can only support 8-bit images.  Also, they entirely sufficient for many tasks and so there is no need to use more complicated and harder-to-process images [2].  Shown below is an image of peppers ion grayscale.

Figure 2. Grayscale Image

GIMP Image Properties

Pixel dimensions:        137 x 137 pixels

Print size:        36.25 x 36.25 millimeters

Resolution:      96 x 96 ppi

Color space:    Grayscale

File Name:       C:\Users\R…Grayscale.jpg

File size:          4.3 KB

File Type:        JPEG Image

Size in memory:                      145.2 KB

Number of pixels:       18769

Source: http://inperc.com/wiki/index.php?title=Grayscale_Images

Scilab Commands

–>imread(‘C:\Users\RnR-\Documents\Rob\Images\Grayscale.jpg’);

Size:   137 rows X 137 columns

Indexed Image

–>size(I)

ans  =

137.    137.    3.

–>imfinfo(‘C:\Users\RnR-\Documents\Rob\Images\Grayscale.jpg’,’verbose’);

FileName: C:\Users\RnR-\Documents\Rob\Images\Grayscale.jpg

FileSize: 4405

Format: JPEG

Width: 137

Height: 137

Depth: 8

StorageType: indexed

NumberOfColors: 256

ResolutionUnit: inch

XResolution: 96.000000

YResolution: 96.000000

Truecolor Image

Most of the colored images belong to this type; they are the images that appear to the human eye as “real” colors i.e. the combination of the additive primary colors of red, green and blue (RGB).  They are undoubtedly the most sophisticated image type since they contain more information as compared to other types, but would consume larger memory. Shown below is an image of what I consider the most amazing man-made structure in the world, the Petra in Jordan.

Figure 3. Truecolor Image

GIMP Image Poperties

Pixel dimensions:        110 x 133 pixels

Print size:        36.61 x 46.92 millimeters

Resolution:      72 x 72 ppi

Color Space:    RGB color

File Name:       C:\Users\R…truecolor.jpg

File Size:         3.5 KB

File Type:        JPEG image

Size in memory:                      189.3 KB

Number of pixels:       14630

Source:            http://www.adventure-travel.org.uk/ASIA/petra.php

Scilab Commands

–>imread(‘C:\Users\RnR-\Documents\Rob\Images\Truecolor.jpg’);

Size:   133 rows X 110 columns

Truecolor Image

–>size(I)

ans  =

133.    110.    3.

–>imfinfo(‘C:\Users\RnR-\Documents\Rob\Images\Truecolor.jpg’,’verbose’);

FileName: C:\Users\RnR-\Documents\Rob\Images\Truecolor.jpg

FileSize: 3563

Format: JPEG

Width: 110

Height: 133

Depth: 8

StorageType: truecolor

NumberOfColors: 0

ResolutionUnit: centimeter

Xresolution: 72.000000

Yresolution: 72.000000

Indexed Image

An indexed image is a practical way of representing color images.  Indexed images are made up of two parts, pixel data and color model data, which is also called as gradient or palette.  Each pixel gets its color equivalent from the color model for the color corresponding to the pixel’s index [3].  Shown below is an indexed image of a mandrill, which was originally a truecolor image, then converted to an indexed image using matlab.

Figure 4. Indexed Image

GIMP Image Poperties

Pixel dimensions:        344 x 327 pixels

Print size:        121.36 x 115.36 millimeters

Resolution:      72 x 72 ppi

Color space:    Indexed color (231 colors)

File Name:       C:\Users\R…Indexed.jpg

File Size:         86.5 KB

File Type:        GIF image

Size in memory:                      1014.3 KB

Number of pixels:       112488

Source:            http://www.mathworks.com/access/helpdesk/help/techdoc/ref/image.html

Scilab Commands

–>imread(‘C:\Users\RnR-\Documents\Rob\Images\Indexed.jpg’);

Size:   327 rows X 344 columns

Indexed Image

–>size(I)

ans  =

327.    344.    3.

–>imfinfo(‘C:\Users\RnR-\Documents\Rob\Images\Indexed.jpg’,’verbose’);

FileName: C:\Users\RnR-\Documents\Rob\Images\Indexed.jpg

FileSize: 88566

Format: GIF

Width: 344

Height: 327

Depth: 8

StorageType: indexed

NumberOfColors: 256

ResolutionUnit: centimeter

Xresolution: 72.000000

Yresolution: 72.000000

Advanced Image Types

There are also image types that are said to be advanced, the following are some of those.  I also posted examples for each type.

High Dynamic Range (HDR) Images

Figure 5. HDR Image

http://www.smashingmagazine.com/2008/03/10/35-fantastic-hdr-pictures/

Multi or Hyperspectral Image

Figure 6. Multi or Hyperspectral Image

http://personalpages.manchester.ac.uk/staff/david.foster/Hyperspectral_images_of_natural_scenes_02.html

3D Images

Figure 7. 3D Image

http://www.3d-images-gallery.com/

Temporal images or Videos

A sample video is posted below

Image Formats

In saving images, I used to wonder which image file format will be the best to use from all the available file formats nowadays.  But I actually don’t care what I’d choose since, for me, the protocol best applicable in this situation is that you go for the default.  Usual image file format default is JPEG, so I used to save almost all my images as JPEG.  However, as I came across this activity, I became concerned with the proper file format that would be appropriate for specific application that I would encounter.  In common usage (i.e. printing, scanning, and internet use), the most common image file formats are TIF, JPG, and GIF.  However, TIF are not useful in internet browsers but they are the default format in some scanners.  A table is shown to below to summarize of the properties of some of the most common file formats.

Image File Format Color data mode
Bits per pixel
TIF (Tagged Image File) RGB – 24 or 48 bits,
Grayscale – 8 or 16 bits,
Indexed color – 1 to 8 bits,
Line Art (bilevel)- 1 bit

For TIF files, most programs allow either no compression or LZW compression (lossless, but is less effective for 24 bit color images). Adobe Photoshop also provides JPG or ZIP compression too (but which greatly reduces third party compatibility of TIF files). “Document programs” allow ITCC G3 or G4 compression for 1 bit text (Fax is G3 or G4 TIF files), which is lossless and tremendously effective (small).

and smaller files.

PNG (Portable Network Graphics) RGB – 24 or 48 bits,
Grayscale – 8 or 16 bits,
Indexed color – 1 to 8 bits,
Line Art (bilevel) – 1 bit

PNG uses ZIP compression which is lossless, and slightly more effective than LZW (slightly smaller files). PNG is a newer format, designed to be both verstile and royalty free, back when the LZW patent was disputed.

or lower quality

JPEG (Joint Photographic Experts Group) RGB – 24 bits,
Grayscale – 8 bits

JPEG always uses lossy JPG compression, but its degree is selectable, for higher quality and larger files,

GIF (Graphics Interchange Format) Indexed color – 1 to 8 bits

GIF uses lossless LZW compression, effective on indexed color. GIF files contain no dpi information for printing purposes

Shown below is another table to serve as a simple guide for choosing file format for general purposes;

Photographic Images Graphics, including
Logos or Line art
Properties Photos are continuous tones, 24 bit color or 8 bit Gray, no text, few lines and edges Graphics are often solid colors, up to 256 colors, with text or lines and sharp edges
For Unquestionable Best Quality TIF or PNG (lossless compression
and no JPG artifacts)
PNG or TIF (lossless compression,
and no JPG artifacts)
Smallest File Size JPG with a higher Quality factor can be decent. TIF LZW or GIF or PNG   (graphics/logos without gradients normally permit indexed color of 2 to 16 colors for smallest file size)
Maximum Compatibility
(PC, Mac, Unix)
TIF or JPG TIF or GIF
Worst Choice 256 color GIF is very limited color, and is a larger file than 24 bit JPG JPG compression adds artifacts, smears text and lines and edges

These are just simple guides using the most common file formats, however, for more sophisticated images and saving images, one can almost opt to use advanced file formats [4].

There are many other formats not discussed in the above tables.  I will just enumerate some of them [5].

  1. BMP (Windows Bitmap) – uncompressed, hence they are large; the advantage is their simplicity and wide acceptance in Windows programs.
  2. EXIF (Exchangeable Image File Format) – incorporated in the JPEG-writing software used in most cameras. Its purpose is to record and to standardize the exchange of images with image metadata between digital cameras and editing and viewing software.
  3. RAW (Raw Image Formats) – family of raw image formats that are options available on some digital cameras. These formats usually use a lossless or nearly-lossless compression, and produce file sizes much smaller than the TIFF formats of full-size processed images from the same cameras
  4. Netpbm format – family that includes PPM (Portable Pixmap), PGM (Portable Graymap),     and PBM (Potable Bitmap). These are either pure ASCII files or raw binary files with an ASCII header that provide very basic functionality and serve as a lowest-common-denominator for converting pixmap, graymap, or bitmap files between different platforms. Several applications refer to them collectively as the PNM format (Portable Any Map).
  5. TGA (TARGA)
  6. ILBM (InterLeaved BitMap)
  7. PCX (Personal Computer eXchange)
  8. ECW (Enhanced Compression Wavelet)
  9. IMG (ERDAS IMAGINE Image)

10.  SID (multiresolution seamless image database, MrSID)

11.  CD5 (Chasys Draw Image)

12.  FITS (Flexible Image Transport System)

13.  PGF (Progressive Graphics File)

Now let me proceed to discussing the specified procedure in the manual.  Here, I obtained information from my scanned image used in the first activity and see its properties using the imread, size, and imfinfo commands in scilab.  The copy of the scanned image and a Print screen image is shown below

Figure 8. Scanned Image fro Activity 1

Figure 9. Print Screen Image of the Scilab codes

Based from the size and from what the Scilab says, the scanned image is a truecolor image.

Let me now analyze and get the properties of some of my scanned images intended for this activity.            The next image is a scanned colored image of a leaf with a flower and the corresponding Printscreen image from the Scilab codes.

Figure 10. Scanned Colored Image

Figure 11. Print Screen Image of the scilab code

The scanned image is a truecolor image similar to the setting when it was scanned.  Let us now see if the scanned image was set to grayscale when it was scanned.  Shown below is a grayscale image with the Print screen code form Scilab.

Figure 12. Scanned Grayscale Image

Figure 13. Print Screen image of the Scilab code

It is still a truecolor image, hmmmm I guess it’s because it was exported to Scilab as it was saved and no image conversion was done like the scanned graph above.  It is, however, confirmed in GIMP.

Figure 14. Print Screen Image of the Image Properties from GIMP

I will now convert a true color image into grayscale and black and white using Scilab.  The image that I will be going to convert is a photo of Lady Gaga, a singer that I really really like :-).

Figure 15. Lady GaGa true color Image

https://5artychickens.wordpress.com/2010/02/20/top-fashion-buzz-of-2010/

Using the code

I=imread(‘C:\Users\RnR-\Documents\Rob\Images\Lady gaga True color.jpg’);

imshow(I);

G = im2gray(I);

imshow(G);

The image of GaGa was successfully converted into grayscale as shown below

Figure 16. Lady GaGa grayscale image

Then using the code below with 0.5 threshold value for the pixel color to turn black or white depending if it exceed or less than the threshold.  The selection of the threshold value here is completely arbitrary, I just chose 0.5 since it’s on the middle 0f 0 and 1.

I=imread(‘C:\Users\RnR-\Documents\Rob\Images\Lady gaga True color.jpg’);

imshow(I);

G = im2bw(I,0.5);

imshow(G);

Figure 17. Lady GaGa Black and White Image

GaGa is now black and white!

Well, I can say that the threshold value was not that ok since some parts of the Region of Interest (ROI) is not distinguishable from the background.  However, this is only a preliminary demonstration of the Scilab’s capability of converting images.  The succeeding discussions will deal more on the thresholding.

Using  histplot(256,I) on the grayscale image of my scanned plot a histogram plot was made.

Figure 17. Histplot of the grayscale image of the scanned plot

The histogram shows that the scanned image is of poor contrast since the plot is just concentrated on an area.  To plot the scanned graph on a black and white mode, I chose a threshold point from the histplot above.  I actually do some trial and error in doing this, and finally I chose 0.96. The threshold is important to distinguish the Region of Interest (ROI) from the background. The black and white image is shown below with the print screen of the Scilab codes.

Figure 18. Black and white image of the scanned plot with threshold of 0.96

The lines, I think, were separated from the background. However, there is a large black area on the image that is a reflection of the poor quality of the scanned image.

Since I am not happy with the contrast of my scanned graph, let me try using my scanned image of the leaf and the flower and do the same concept in doing the black and white image.

The grayscale image is shown below

Figure 19. Grayscale image converted from the scanned colored image from Figure 10

Now for the histplot…

Figure 20. Histplot of the grayscale image above

Now I can say that I have obtained a scanned image of high contrast as shown by the more distributed plot. 🙂 So for the the black and white image, the threshold was set to 0.7 (not too light, not too heavy). The black and white image is shown below

Figure 21. Black and white image of the scanned Leaf and flower (at llast-my Final Image for this blog)

For this image, I can say that the ROI is already well-distinguished from the background.

There there…I think I’ve done all the required things to do on this activity.  I rate myself 10/10 for doing all the required things to do [and even slightly exceeding]. I acknowledge Xylene Azurin for helping me with the histplot. Thank you very much, Xy

References:

  1. Binary Images. http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT2/node3.html
  2. Grayscale Images. http://homepages.inf.ed.ac.uk/rbf/HIPR2/gryimage.htm
  3. Indexed images  http://www.cylekx.net/help/indexed_images.htm
  4. Image File Formats – TIF, JPG, PNG, GIF. Which to use? http://www.scantips.com/basics09.html
  5. Image File Formats. http://en.wikipedia.org/wiki/Image_file_formats

One response to this post.

  1. digital cameras are really great because you can shoot and preview the pictures right away :;.

    Sagutin

Mag-iwan ng puna