Act 3. Image Types and Formats
Images are data with varied importance depending on where it will be used. Each type of image and file formats have its pros and cons, for one, some formats are lossy in terms of details but are more handy in terms of compression or the other way around. Knowing these information about images helps us determine which type and format is appropriate for which application.
There are four basic types of images:
Binary
Size: 100 rows X 100 columns
Binary Image
FileName: D:\files\kaye\186\square.jpg
FileSize: 592
Format: JPEG
Width: 100
Height: 100
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: inch
XResolution: 72.000000
YResolution: 72.000000
Binary images are those that are composed of only two colors. Each pixel are either balck or white only, no in betweens. The information were provided by Scilab 4.1.2 which could be access through the command imfinfo(‘file’, ‘verbose’) after the image has been loaded to Scilab via the imread(‘filename’) syntax.
Indexed
Size: 248 rows X 248 columns
Indexed Image
FileName: D:\files\kaye\186\indexed.gif
FileSize: 27065
Format: GIF
Width: 248
Height: 248
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
Indexed images work by having a representation for each major color in an image thus making it good for compression since the image is divided into two data set that take up less memory space – a matrix filled with the color representation, usually from values 0 to 255, and the color palette to be associated. However, if the palette got mixed up the image may turn out to be very different from the original. The binary image is a special case of indexed image only here the values are restricted to 1 or 0.
Grayscale
Size: 493 rows X 740 columns
Indexed Image
FileName: D:\files\kaye\186\grayscale.jpg
FileSize: 86990
Format: JPEG
Width: 740
Height: 493
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: inch
XResolution: 300.000000
YResolution: 300.000000
Grayscale images unlike binary ones are composed of blacks and whites and their gradient. If indexed, it is composed of values between 0 and 1.
True Color Images
Truecolor Image
FileName: D:\files\kaye\186\true color.jpg
FileSize: 12350
Format: JPEG
Width: 300
Height: 469
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
Aside from the basic types, we also have more advance types of images such as the following:
File formats of images are also important in having the appropriate image for a certain application. Knowing the differences between each format can help in determining which is best at which instance. Some of the common formats are as follows:
JPEG (Joint Photographic Extension Group)
File extension : .jpg
RGB – 24 bits
Grayscale – 8 bits
Jpeg is considered as a lossy compression for an image file however, it has an option on how large the file will be making it flexible for the most part. It may be used for files that are not too dependent on every inch of its details. It is good for photographic images but not for graphics and the likes.
GIF (Graphics interchange Format)
Indexed color: 1- 8 bits
File extension: .gif
Gif is a lossless file compression format sharp-edged arts like logos and small animations that require only a few colors. Gif is limited to 256 colors making it not suitable for high quality photographs.
TIFF (Tagged Image File Format)
RGB – 24 or 48 bits,
Grayscale – 8 or 16 bits,
Indexed color – 1 to 8 bits
File extension: . tif
TIFF uses a lossless compression technique known as LZW which makes it appropriate for instances which makes use of every bit of detail in an image such as xray scans. TIFF can be considered as the best file format among all however it has also its own downside. When used in photo images, Tiff files tend to eat up so much space since it does not compress much. Aside from this, TIFF is also not compatible with internet browsers.
Conversion of file formats
The final part of this activity deals with the conversion of the image type or format.
Using Scilab 4.1.2 and SIP toolbox, a true color image is loaded into it and is manipulated. Using im2gray and im2bw syntax the image is converted into a grayscale image or binary image respectively. Using the histplot command, the component color of the image was determined. The data provided by the histogram also helped determine the threshold level that must be set such that the the binary converted image can have a good contrast.
From the histogram plot we could see that the value of the most number of pixel lie between 0.85 and 1. Since we know that majority of the pixels lie in the background we can say that those with values between 0.85 and 1are part of the background. With this we set the threshold level to 0.80 which effectively set all pixel pixel values below or equal this level to 0 while those higher than this to 1 thus turning the image to a binary image.
We can see that this edited image of the same graph is much cleaner and the lines are much clearer.
—
I will give myself a 10 for this activity since I was able to give all the necessary outputs and I understood the concepts presented.
—
References:
[1] http://www.scantips.com/basics09.html
[2] http://www.scantips.com/basics9t.html
[3] http://en.wikipedia.org/wiki/JPEG
[4] http://en.wikipedia.org/wiki/Graphics_Interchange_Format
for the pictures:
grayscale: http://www.pixelperfectdigital.com/free_stock_photos/data/509/medium/grayscale_flower.jpg
indexed: http://star.pst.qub.ac.uk/idl/images/imgcolor16.gif
true color: http://www.spacew.com/gallery/image004202-thumb.jpg
HDR : http://farm2.static.flickr.com/1047/1156912539_ecd588a316.jpg
hyperspectral : http://rst.gsfc.nasa.gov/Sect13/HyMap_Zack_3D_cube.jpg
3d: http://drawn.ca/wordpress/wp-content/images/nightmare3d.jpg
temporal image: http://www.freefever.com/animatedgifs/animated/wave2.gif
Scilab Code:
stacksize(100000000);
// basic types
binary= imread(‘D:\files\kaye\186\square.jpg’);
imfinfo(‘D:\files\kaye\186\square.jpg’, ‘verbose’);
indexed = imread(‘D:\files\kaye\186\indexed.gif’);
imfinfo(‘D:\files\kaye\186\indexed.gif’, ‘verbose’);
grayscale = imread(‘D:\files\kaye\186\grayscale.jpg’);
imfinfo(‘D:\files\kaye\186\grayscale.jpg’, ‘verbose’);
truecolor = imread(‘D:\files\kaye\186\true color.jpg’);
imfinfo(‘D:\files\kaye\186\true color.jpg’, ‘verbose’);
// advance types
hdr = imread(‘D:\files\kaye\186\HDR.jpg’);
imfinfo(‘D:\files\kaye\186\HDR.jpg’, ‘verbose’);
hyperspectral = imread(‘D:\files\kaye\186\hyperspectral.jpg’);
imfinfo(‘D:\files\kaye\186\hyperspectral.jpg’, ‘verbose’);
3d = imread(‘D:\files\kaye\186\3d.jpg’);
imfinfo(‘D:\files\kaye\186\3d.jpg’, ‘verbose’);
//converting
//black and white
bw_highmax =im2bw(truecolor, 0.7);
bw_lowmax = im2bw(truecolor, 0.3);
scf(1), imshow(bw_highmax);
imwrite(bw_highmax, ‘D:\files\kaye\186\bw_highmax.jpg’);
scf(2), imshow(bw_lowmax);
imwrite(bw_lowmax, ‘D:\files\kaye\186\bw_lowmax.jpg’);
//grayscale
gray = im2gray(truecolor);
imshow(gray);
histplot(256, gray);
//from act 1
act1 = gray_imread(‘D:\files\kaye\186\act1 graph.jpg’);
scf(3), imshow(act1);
scf(4), histplot(256, act1);
bw= im2bw(act1,0.8);
imwrite(bw, ‘D:\files\kaye\186\bwtreshold.jpg’);
scf(5), imshow(bw);
Indexed Image
FileName: D:\files\kaye\186\square.jpg
FileSize: 592
Format: JPEG
Width: 100
Height: 100
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: inch
XResolution: 72.000000
YResolution: 72.000000