Activity 3: Image Types and Formats
Usually, when looking or saving images, it wouldn't matter to me what file type should i save it to so long as I am able to see it though my device (phone, ebook reader. However if I wish to save space, I usually save it in multiple file formats and choose the least file size it was saved to (which is usually jpeg).
The same scanned graph from my Activity 1 was used. Note that there are certain parts that are somewhat light, as well as the lines not as sharp (or dark) as a computer-made graph would be. As such, the same program was used for the this image.
Notice the evident difference between the two images after the application of the program. The original image was a bit lighter, but with the new image, the lines has become sharper and more noticeable.
The code for this activity is given below.
I = [];
stacksize(100000000);
fname = 'hdr-fire-clouds';
fext = '.jpg'; //filename of image
floc = 'd:\Users\Isabel\Desktop\AP186 - Activity 03\'; //file location
I = imread(strcat([floc, fname, fext])); //reads the image
//converts to black&white with varying threshold
th = [0,0.2,0.3,0.4,0.5,0.6,0.7,0.8,1.0]';
for i = 1:length(th)
bw = im2bw(I, th(i)); //converts image to black&white (boolean)
bw = bool2s(bw); //converts boolean to 1/0
imwrite(bw, strcat([fname,'_bw_',string(th(i)), '.png']));
end
//converts to grayscale
gray = rgb2gray(I);
bw = im2bw(I, th);
imwrite(gray, strcat([fname,'_gray', '.png']));
[counts, cells] = imhist(gray);
//plot(cells, counts);
//setting threshold value
thresh = mean(find(counts==max(counts)))/255;
bw_thresh = im2bw(gray, thresh);
bw_thresh = bool2s(bw_thresh);
//saves the image to mutiple file types
imwrite(bw_thresh, strcat([fname,'_png_', string(thresh), '.png']));
imwrite(bw_thresh, strcat([fname,'_jpg_', string(thresh), '.jpg']));
imwrite(bw_thresh, strcat([fname,'_tif_', string(thresh), '.tif']));
imwrite(bw_thresh, strcat([fname,'_bmp_', string(thresh), '.bmp']));
For this, I give myself a 10/10 since I was able to produce the all the required output. For this, I would like to thank Tin Roque for great insights! Salamat talaga.. Okay lang kahit na-late tayo sa pag-uwi, malakas naman ang net.. :P
References:
File format information:
http://www.dslreports.com/faq/12898
http://support.microsoft.com/default.aspx?scid=kb;en-us;272399
Indexed:
http://www.matkk.com/colormap.html
Binary:
http://boofcv.org/index.php?title=Example_Binary_Image
Multispectral:
http://www.holovachov.com/p200360707/h3269DC34#h52bd386
http://www.fas.org/irp/imint/docs/rst/Intro/Part2_24.html
High-dynamic range:
hazelsteel.wordpress.com
designsdelight.com
milesunit.com
3D:
flickriver.com
digitalcameratracker.com
Spectrum:
jay-han.com
Scanned image:
Alarcon, Minella, Optical remote sensing of gases using low-loss optical fiber line in the near-infrared region, 1986
Image Types
So to remedy this, I researched the different characteristics of image formats and types. There are several known image types: binary, grayscale, truecolor, indexed, high-dynamic range, multispectral, and 3D images. Examples of these images are shown below:Binary
![]() |
| Binary image with corresponding properties using imfinfo() |
Grayscale images
True color images
| Tr image with corresponding properties using imfinfo() |
Indexed images
Multispectral images
![]() |
| Multispectral image with corresponding properties using imfinfo() |
| Multispectral image (clockwise from top left): infrared, ultraviolet, false color vision, multispectral |
High-dynamic range images
![]() |
| High-dynamic image with corresponding properties using imfinfo() |
![]() |
| High-dynamic image with corresponding properties using imfinfo() |
3D images
![]() |
| 3D image with corresponding properties using imfinfo() |
![]() |
| High-dynamic image with corresponding properties using imfinfo() |
Image Formats
Other than the image types, we were also asked to research about the different image formats. What is interesting about this topic is that most people (including me! before..) is generally not familiar with the major differences. What mostly matters is whether it is still clear and has small file size (even for large image). To remedy this, properties, advantages and disadvantages of these formats is discussed.
TIFF
This is short for tagged image file format. The image with this format has a file extension of .tif or .tiff. This stores a single image at any color depth. At this format, we can modify the original specification to meet specific parameters.
Advantage:
Widely supported (Macintosh and Window-based)
Optional compression (there is no loss in color information, any color depth)
Disadvantage:
Disadvantage:
Since no loss in color, usually has large file size
Not supported by web browsers
PNG
Short for portable network graphic. Stores image at any color depth. This has a file extension of .png.
Advantage:
Supports high level of lossless compression
Alpha channel transparency
Gamma correction
Interlacing
Supported by wed browsers (recent)
Disadvantage:
Less compression that JPG (against JPEG)
Do not support animated files (like GIF format)
JPEG
Short for Joint Photographic Experts group. This has a file extension of .jpg or .JPEG. This stores the image in a 24-bit color. It supports the highest levels of compression and this compression is lossy where color information and detail is lost from the original (RAW).
Advantage:
Variable compression (can control file size)
Usually has small file size
High compression
Supported by web browsers
Disadvantage:
Compression degrades original image
When editing, the resaving to JPEG has comulative degredation
Not suitable for simpler images (small range color, monochromatic, or stark difference in brightness)
BMP
This is Windows bitmap with a file extension of .bmp. This stores the image in any color depth, black and white to 24-bit. This is compatible with Microsoft windows programs.
Advantage:
1-bit to 24-bit color depth
Compatible with Windows
Disadvantage:
No compression, which result in very large files
Not supported by web browsers
GIF
Short for Graphics Interchange Format. It has file extension of .gif. These images are animated (moving with loop lasting every few seconds). This stores the image in 8-bit (256 colors).
Advantage:
Supported internet standard
Lossless compression
Transparency supported
Easy to create
Disadvantage:
Loss of color information for images with larger bit-depth (detailed images will appear paletted)
Lossless compression is inferior to JPG or PNG (most cases)
Limited transparency
Scilab: Image types and formats
After comparing the advantages and disadvantages of each file format, it is evident that depending on what purpose would you use the image would the appropriate file format should be. However as someone who applies mathematical operations and a programmer who needs the exact information captured by the camera without any alteration, it is important to save it as TIFF. As someone who only uses an image for Facebook or as such, it is more convenient to save it as JPG or PNG to save memory.
Now, I chose an image from the net to modify: convert to black and white as well as save to different file formats. A true color image (color spectrum) was searched from the internet. This is the image below. The image was then converted to binary and gray scale. For the conversion of the image to binary, there is an additional parameter which is the threshold. This threshold determines at which intensity (in grayscale) will there be the cut-off between assigning the value 0 or 1. Using imhist(), the graylevel histogram was examined. Using the information from the histogram (maximum, minimum, etc), I designated a specific threshold for the image. Afterwhich, the images were saved into multiple file formats. [Program at the bottow]
![]() |
| True color image |
![]() |
| Grayscale image |
![]() |
| Black and white image with threshold=0.003 |
![]() |
| Image for varying thresholds (0 to 1) |
![]() |
| Black and white with threshold=0.003 saved in various file formats |
![]() |
| Original image (High-dynamic range) |
![]() |
| Image for varying thresholds (0 to 1) |
![]() |
| Original scanned image (from Activity 1) |
![]() |
| Black and white image with threshold=0.5 |
![]() |
| Black and white image with threshold=0.8 |
The code for this activity is given below.
I = [];
stacksize(100000000);
fname = 'hdr-fire-clouds';
fext = '.jpg'; //filename of image
floc = 'd:\Users\Isabel\Desktop\AP186 - Activity 03\'; //file location
I = imread(strcat([floc, fname, fext])); //reads the image
//converts to black&white with varying threshold
th = [0,0.2,0.3,0.4,0.5,0.6,0.7,0.8,1.0]';
for i = 1:length(th)
bw = im2bw(I, th(i)); //converts image to black&white (boolean)
bw = bool2s(bw); //converts boolean to 1/0
imwrite(bw, strcat([fname,'_bw_',string(th(i)), '.png']));
end
//converts to grayscale
gray = rgb2gray(I);
bw = im2bw(I, th);
imwrite(gray, strcat([fname,'_gray', '.png']));
[counts, cells] = imhist(gray);
//plot(cells, counts);
//setting threshold value
thresh = mean(find(counts==max(counts)))/255;
bw_thresh = im2bw(gray, thresh);
bw_thresh = bool2s(bw_thresh);
//saves the image to mutiple file types
imwrite(bw_thresh, strcat([fname,'_png_', string(thresh), '.png']));
imwrite(bw_thresh, strcat([fname,'_jpg_', string(thresh), '.jpg']));
imwrite(bw_thresh, strcat([fname,'_tif_', string(thresh), '.tif']));
imwrite(bw_thresh, strcat([fname,'_bmp_', string(thresh), '.bmp']));
For this, I give myself a 10/10 since I was able to produce the all the required output. For this, I would like to thank Tin Roque for great insights! Salamat talaga.. Okay lang kahit na-late tayo sa pag-uwi, malakas naman ang net.. :P
References:
File format information:
http://www.dslreports.com/faq/12898
http://support.microsoft.com/default.aspx?scid=kb;en-us;272399
Indexed:
http://www.matkk.com/colormap.html
Binary:
http://boofcv.org/index.php?title=Example_Binary_Image
Multispectral:
http://www.holovachov.com/p200360707/h3269DC34#h52bd386
http://www.fas.org/irp/imint/docs/rst/Intro/Part2_24.html
High-dynamic range:
hazelsteel.wordpress.com
designsdelight.com
milesunit.com
3D:
flickriver.com
digitalcameratracker.com
Spectrum:
jay-han.com
Scanned image:
Alarcon, Minella, Optical remote sensing of gases using low-loss optical fiber line in the near-infrared region, 1986



























Comments
Post a Comment