Monday, July 22, 2013

A10 - Morphological Operations

A9 - ColorImage Segmentation

A8 - Enhancement in the Frequency Domain

A7 - Fourier Transform Model of Image Formation

A6 - Enhancement by Histogram Manipulation

A5 - Area Estimation for Images with Defined Edges


    Green's Theorem is a very useful way to compute areas ( or perimeters) of regions if one or the other is known. Supposing we have region R similar to the one shown in the Figure below

If we  take the counterclockwise direction to be the positive one then Green's theorem is given by


If we take C to be the collection of points in the boundary of R , choosing F1 = 0 and F2 = x gives us the equation below each relating a closed line integral to the area of R





Adding the two equations and averaging, we get

Which written in summation form and setting Nb to be t he number of pixels in the boundary of R then we have

I first created a circle of radius 0.7 using a code similar to the one I used in the Activity Scilab basics

stacksize(100000000);
nx = 500; //defines the number of elements along x and \y
ny = 500;
x = linspace(-1,1,nx);//defines the range
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);//creates two 2-D arrays of xand y coordinates
r = sqrt(X.^2 + Y.^2);//note element-per-elementsquaring of X and Y
A = zeros(nx,ny);
A(find(r<0.701)) = 1;
imshow(A);

with theoretical area pi*.7^2 = 1.53938



using the code 


nx = 500; ny = 500; //defines the number of elements along x and y
x = linspace(-1,1,nx); //defines the range
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y); //creates two 2-D arrays of xand y coordinates
r= 0.401; // side of the square
S = zeros (nx,ny);
S (find (abs(X)<r & abs (Y)<r))=1;
imshow(S);
to form a square of side .4 with theoretical area .16





A4 - Image Types and Formats

This activity entailed the familiarization of different image types and formats

A.) Image Types

1.) Binary Images
Binary Images are black and white images with pixel values 0 OR 1. This means that one pixel is one bit. Fonts/text, fingerprints, particle tracks and signatures are some images whose information can be adequately saved in binary form




Using the info = imfinfo(filename) function of Scilab I got the properties :

Filename: C:\Users\Vyke\Desktop\Activity 4\ablackandwhite.png  
FileSize:    19827. 
Width:    800. 
Height: 771. 
BitDepth   8         
ColorType:truecolor

2.) Grayscale Images
Grayscale images
Grayscale images are images that are black AND white with each pixel (picture element) having a value that ranges from 0 to 256 with 0 being pure black and 256 pure white. Different values correspond to different intensities of “grayness” A value of 256 corresponds to the data stored in 8 bits or 1 Byte (28). Graytone information similar to the ones found in x-rays and microscopic slides benefit greatly from grayscale images.



Filename:   C:\Users\Vyke\Desktop\Activity 4\audreygray.jpg
FileSize: 121635. 
Width:   420. 
Height: 563. 
BitDepth: 8         
ColorType :grayscale

3.) Truecolor Images
Truecolor images have pixels with three channels each of an intensity (that ranges from 0 to 256) of red, blue or green light. These channels are composed together to create other colors. Each pixel has 2563 possible colors. A lot of images come in truecolor form with a 256x256 pixel image having a size of 256 x 256 x 3 because each pixel has 3 channels each with 1 BYTE of memory.



Filename: C:\Users\Vyke\Desktop\Activity 4\audreytruecolor.jpg  
FileSize:    65180. 
Width: 430.
Height: 500.
BitDepth   8 .     
ColorType :truecolor

4.) Indexed Images
Indexed images are used when images with lesser detailed is needed, but that compensate with less memory (smaller data or color information) needed for the image. These images have two sets of data, the image itself, and its index, which are numbers that refer to colors in a color map. 


Filename: C:\Users\Vyke\Desktop\Activity 4\clownindex.png  
FileSize: 64993. 
Width:    560. 
Height: 420.
BitDepth   8 .     
ColorType :truecolor

5.) High dynamic range (HDR) images
Images of digital x-rays, plasma, nuclear explosions require more that regular 8 bits. The images are instead stored in 10 bits or 16 bits to achieve more detailed images.





Filename: C:\Users\Vyke\Desktop\Activity 4\hdr.jpg  
FileSize:  1472750. 
Width: 1920. 
Height: 1200.
BitDepth   8 .     
ColorType :truecolor


6.) Multi or Hyperspectral
Satelite images are examples of images that make use of more the 3 channels that correspond to the primary colors and instead have up to 100 channels (in the case of hyperspectral images).


Filename C:\Users\Vyke\Desktop\Activity 4\hyperspectral.jpg  
FileSize: 93967. 
Width: 432 
Height: 341
BitDepth   8 .     
ColorType :truecolor

7.) 3D Image
3D images are produced by either using: point clouds ( x,y,z) to store spatial data  or even several 2D cross sections piled on top of each other forming image stacks as in medical scans. These all generate the spatial properties integral to 3d images.


Filename : C:\Users\Vyke\Desktop\Activity 4\3d.jpg  
FileSize: 489617. 
Width: 800
Height: 548
BitDepth   8 .     
ColorType :truecolor

8.) Temporal images or Videos
These are images the move with time. 




B. Image Formats

Images can be saved under different formats to suite your needs. Images can be significantly reduced in size to cater to storage limits or can be saved to preserve quality.
Images in different file formats will have different properties. There are two ways images can be saved: lossy and lossless. Lossy compression techniques create very compressed files with some loss in image data. These create images that aren’t as detailed as the original ones but the changes are ignorable or irrelevant. Lossless compression maintains the original image data with no loss of data for every pixel. These are very important when even minute details of an image are important.

JPEG
JPEG stands for Joint Photographic Experts Group and are used particularly for photographic pictures. This is the standard format for images taken with digital cameras and for photographic images in general. JPEG formats utilize the lossy compression meaning that some of the original image information is not retained but are highly compact. This makes it very easy to edit and makes JPEG files extremely flexible. JPEG compresses files by retaining elements in an image that matter the most and capitalizes on image contrast to decide what details to keep. This therefore makes noisier images harder to compress that less noisier ones

TIFF
TIFF stands for Tagged Image File Format and is widely used in printing and publishing. There make use of lossless compression techniques keeping images more detailed but at the same time making them bigger in size. Multiply layered images can easily stored in one TIFF. They are excellent for images that need to be kept first and archived.

GIF
GIF stands for Graphics Interchange Format and are images that can produce moving images by displaying images sequentially. GIF images produce images that are not as detailed as original ones because 256 colors are maintained from an image with originally a lot more. GIF images load segment-by-segment using interlacing. Images stored in GIF are optimal for logos graphs and other images where color detail in unimportant but transparency is. GIF supports transparency.

PNG
PNG stands for Portable Network Graphics and are an excellent substitute to GIF images. PNG can compress images 5% to 25% more than in GIFs and support variable transparency. This means users can decide on how transparent an image can be but whose drawback are inconsistencies in displaying transparency depending on the browser. PNG utilizes 2D interlacing making them load twice as fast as GIF images.

SVG
SVG or Scalable Vector graphics allows very good quality graphics and animation that retain detail even when increasing the size of the image. This can create images that looks the same whether it’s the size of a small icon or scaled to fit a huge monitor. SVG can be applied to still images and moving ones.


C.

Choosing the image I used as an example for a truecolor image, A truecolor picture of Audrey Hepburn, I will demonstrate the SIVP functions by turning it to a grayscale image and to a black and white image.

Using the code

im = imread('C:\Users\Vyke\Desktop\Activity 4\audreytruecolor.jpg');
gim= rgb2gray(im);
imshow(gim)

I successfully turned into a grayscale image




using the code snippet shown below:

im = imread('C:\Users\Vyke\Desktop\Activity 4\audreytruecolor.jpg');
bim= im2bw(im,0.4);
imshow(bim)

I turned it into a black and white image





References:

[1] "Activity 3: Image Types and Formats 2010", Dr. Maricor Soriano

[2]http://www.cambridgeincolour.com/tutorials/imagetypes.htm

[3] http://www.practicalecommerce.com/articles/1821-Image-Formats-What-s-the-Difference-Between-JPG-GIF-PNG-