Thursday, 31 January 2013

Image resolution terminology

There are some specific terms which are widely used in image resolution .We need to know the meaning of them.Some of them are explained below:-

DPI(Dots per Inch):-Dots per inch is measure of spatial printing or video dot intensity.Simply the no of individual dots placed in a line within the span of one inch. Basically DPI refers to the output resolution of a printer or image setter.DPI refers to the physical dot density of an image when it is reproduced as a real physical intensity.

PPI(Pixel per inch):-It is also called pixel density.It is a measurement of the resolution of devices of various context typically in computer displays,image scanners ,digital camera ,image sensors etc.

Calculation of PPI  for monitor:-

                                               PPI=Dp/Di
                               
Where Dp=diagonal resolution in the image
           Di=diagonal size in inches
Dp is calculated from following formula:-\

d_p = \sqrt{w_p^2 + h_p^2}

where Wp is width resolution in pixels
          Hp is height resolution in pixels

Dots Per Pixel:-Dots per pixel is an unit of image resolution which describes the no of dots available in per pixel.In RGB color space  there is 3 dots per inch.

Dots Per Centimeter:- Dots per centimeter or dpcm is a unit of resolution used as metric alternative to Dpi .It is used in CSS3 media queries among other standards.

Lines Per Inches:- Lines per inch is a unit of printing resolution in systems that uses a halftone screen.It is a measure of how close together the lines in a halftone grid are.High value of LPI shows greater detail & sharpness.

Samples Per Inch:- Samples per inch(SPI) is a measurement of the resolution of image scanners.in particular the no of individual samples that are taken in the space of one linear inch.The high value of SPI indicates more detailed its reproduction of scanned object.

Pixel Pitch:-A linear measurement of approximate width of one pixel is known as pixel pitch.In Other words center to center distance between individual pixel in micrometer is called pixel pitch.

False color

Today I wrote a program to generate false color image with a different method .In this method we change the sequence of RGB channels with three methods :
1)BGR - > BRG
2)BGR - > RGB
3) BGR - > GBR

Here are the input & output Images for these operations:-

                                                   Input Image



Output Images:-





There are various other color rendering method used which are explained below:-
1)Pseudo Color
2)Density Slicing
3)Chloropleth

1)Pseudo Color:-A pseudo color is derived from a gray scale by mapping each intensity value to a color according to a table or function.Pseudo color is typically used when a single channel data is available while
false color is used when all three channel data is available . A typical example of pseudo color is thermography where infrared cameras feature single spectrum band & show their gray scale images in Pseudo color.Another familiar example of pseudo color is encoding of elevation using hypsometric tints in physical relief maps.Pseudo color makes some details more visible.For adding geographical information,combining information obtained from infrared & ultra violet light or MRI scan.

2)Density Slicing:-Density slicing is a variation of pseudo color .It divides an image into few colored bands
& is used in analysis of  remote sensing images .For density slicing ,the range of gray scale divides into interval ,with each interval assigned to one of a few discrete colors. This is a contrast to pseudo colors which uses a continuous color scale.

3)Chloropleth:-Chloropleth is an image or map in which areas are colored or patterned proportionally to the category or value of one or more variables being represented.The variables are mapped to a few colors.
Each area contributes one data point & receives one color from these selected colors.A chloropleth map of geographical area is a extreme form of false color.


Uses Of False Color:- False color is widely used in astronomy & medical science .In Astronomy it is widely used for satellite & space images .It is used in remote satellite .For example,space telescope like hubble space telescope,aircraft like rovers mostly uses the false color for their operations.Weather Satellite also uses false color.
                              In medical science it has a very useful application .It increase the visibility of some details .In MRI scan this is widely used .

Negative of an Image:-Negative of an image convert brightest part of an image to the darkest part  & darkest part to the brightest part.If we substract the each intensity value to 255.Today,I wrote a program to convert a color image & gray scale to their negatives.Here is the input & output Image for this program.

Input Images:-




Output Image:-



Wednesday, 30 January 2013

Image Size (Padding & color table)

Simply,we think that the pixel array size is only depends upon image width & image height but there is an issue in this that a row size will be always multiple of four it means if width of image is not in multiple of 4   .Then the row size will be made to multiple of 4.we can check it through taking any image. For example,
If there is 24-bit image of image width 800 & image height 1274 .Then there is no need of padding because the image width is in multiple of 4 bytes.But if we take an image of 24-bit with image width 1274 & image height 800. We need padding of two bytes in each row So image size increased with 800*2*=1600 bytes.Thus if we have a 24-bit image with image width 1274 & image height 1274 then we need same amount of padding because the padding is only needed for the width.The same theory is applied to the 8-bit image but there is a color table added to the image which has a size of 1024 bytes.

Monday, 28 January 2013

Type of Bitmaps

Here we need to discuss some left topics in image processing Which are briefly explained below:-

Binary Images:-Binary image is a digital image which has only two possible values for each pixel.It means each pixel is stored in one bit.So we can easily say that this type of images are Black & white are monochromatic.
8-bit Color Image:-8-bit color images are having 8-bit in one pixel .It means every pixel is stored in one byte & the maximum no of colors that can be generated are 256.In 24-bit color image we can easily understand the RGB channel distribution because there is one byte for each channel. But here is 8 bit or 1 byte reserved for all three channels .So here is only two bit for blue color channels & 3 bits for Red & Green Channels.
Deep Colors:-  30/36/48 -bit color images are called deep color images .They are used with sRGB,xvYcc & YCbCr.
* 24-bit images are called True color images .They use 2^24 colors .
*15/16 -bit color images are called high color images.



*In each color model we can use 2^n possible color values where n is the value of color depth.It means if there is a color image of 8-bit then we can use 2^8=256 colors in that image.

False colors:-False colors are usually having 256 shades with no relation with the real colors of original images .These images are used artificially colorized the grayscale  image to reveal the pixel information .
False colors are used mainly in scientific applications like astronomy,radioastronomy,satellite land imaging,thermography,study of materials ,tomography &magnetic resonance imaging in medicine.

Today ,I wrote a program for false color in image it is the output of reducing a char value reducing to 255. So It is easily clear with 24-bit input & output images of this program.
Input Image:-


False Color Image





8-bit Input Image 



Negative Or False Color image







Friday, 25 January 2013

Sequence of RGB channels in Bitmap Image

It is very necessary to know what is the sequence of RGB channels in Bitmap ?As the name indicates it should be in RGB sequence means first we read red channel,after that green channel & then Blue channel But it is not true .The original sequence of RGB channels is BGR.It means we read Blue channel firstly,Green channel secondly & red channel at the last.We can verify it by taking three pure Red,Green & Blue 24-bit bitmap images.Then We need to read first three character of each of the image.We find that the value of first three character of blue image is 255,0,0 while values of first three characters of Green is 0,255,0 & values of first three character of red image is 0,0,255.Thus it is proved that the sequence of RGB channels in bitmap image is BGR.So we should be careful while using this.

Output of the program:-

Thursday, 24 January 2013

Colors In Image processing

Here are some types of color which we are used in color processing.We are discussing them one by one:-

Additive Colors or Primary colors:-Red,Green & Blue colors are called additive colors Because they makes a RGB model which is produce by adding these three colors in various ways & gives broad array of colors.These three colors are superimposed together to form the mixture .Each color has a intensity value from 0 to highest specified value they can be vary between these two value .If we mix together all the three colors with their minimum value then the output color is dark means black & If we mix these colors with their highest values then we get a brightest color which is white.Additive colors are device dependent their combination may vary from one device to another.Typical input devices in which we use additive color model are Video cameras ,digital cameras & scanners while output devices are LCDs,LEDs ,plasma Tvs,computer & mobile phone displays & video projectors.They are also called primary colors because our eyes highest sensible for these three colors .Almost all colors which we can see through our eyes are combination of only these three colors.

Subtractive Colors or Secondary Colors:- Cyan,Magenta & Yellow colors are called subtractive colors.These colors can be produce by adding two of three primary colors in equals proportions .Cyan color is produce by adding Green & Blue ,Subtractive colors are widely used in color printing,inkjet printing &
photographic color processes.Magenta color is produce by adding red & blue in equal proportion,while yellow color is produce through mixing green & red colors in equal proportions.Thus we can say that cyan is complement of red that means cyan serves as a filter that absorbs red ,Magenta is complement of green that means magenta serves as a filter that absorbs green  & yellow is complement of blue that means yellow serves as a filter that absorbs blue.The amount of cyan applied to a white sheet controls how much red from white light reflected back from the paper.The cyan color is completely transparent to blue & green light & it has no effect on those part of spectrum.This theory is also applied to the magenta & yellow for their corresponding colors.These colors are also called secondary colors because they are produced by the primary colors to create a wider range of colors.

Tertiary Color:-Tertiary color is a color which is made by mixing either one primary color with one secondary color or two secondary colors in a given color space like RGB which is a modern color space
or RYB which is a traditional color space.Tertiary colors have the specific set of names one for RGB & one for RYB.Here are some tertiary color in RGB color space & made by mixing one primary & secondary color.

  cyan(●)+blue(●)=azure(●)
blue(●)+magenta(●)=violet(●)
magenta(●)+red(●)=rose(●)
red(●)+yellow(●)=orange(●)
yellow(●)+green(●)=chartreuse(●)
green(●)+cyan(●)=spring green(●)

In RYB color space primary colors are Red ,Yellow & Blue .The secondary colors which are orange ,green & violet they are made by combining primary colors.Tertiary color are named by combining their name.

red(●)+orange(●)=vermilion (red-orange)(●)
orange(●)+yellow(●)=amber (yellow-orange)(●)
yellow(●)+green(●)=chartreuse (yellow-green)(●)
green(●)+blue(●)=viridian (blue-green)(●)
blue(●)+purple(●)=violet (blue-purple)(●)
purple(●)+red(●)=magenta (red-purple)(●)



Neutral Color:- There are only three neutral colors Black,White & Grey .Basically a neutral color is a monochromatic color.Black color made due to mixture of smallest intensities of Red ,green & blue channels.White color made due to mixture of highest intensity value of Red ,Green & Blue Channels.Grey color is a intermediate between black & white which is achromatic color .It has the all red,green & blue channels value equal in a pixel.This color has wide use in image processing.

Complementary Colors:-Two colors are called complementary if they exactly opposite in a specific color model .Like red & cyan,green & magenta,yellow & blue are complementary to each other in RGB color model .If they are mixed in proper proportion they resulted a neutral color means black,white or grey.Purple & green,orange & blue ,yellow & violet are complementary in RYB color model.

Analogous Colors:-Analogous colors are group of colors which are adjacent to each other in color wheel.One of them will be a dominant color & must be a primary or secondary color & other colors will be tertiary.But this scheme has contrast & is less vibrant than complementary colors.Example of analogous colors are given below:-

1)red,red-orange,red-violet
2)blue,blue-violet,blue-green
3)yellow,yellow-orange,yellow-green
4)green,yellow-green,blue-green
5)violet,blue-violet,red-violet
6)orange,red-orange,yellow-orange.  

Wednesday, 23 January 2013

Bit Planes

A bit plane is of a image is a set of bits corresponding to a given bit position in each of the binary numbers representing the image .For example ,for 16-bit data representation there are 16 bit planes.The first bit contains the set of  most significant bit & the 16th bit contains the least significant bit.The first bit plane gives the roughest but the most critical approximation of values of a medium & the higher the no of bit planes,the less is its contribution to the final stage.Thus adding a bit plane gives a better approximation.Bit plane should not be confused by Bitmap because bit plane refers to the location of the data while bitmap refers to the data itself. In the bit plane replacement of most significant bit shows more distortion in than the distortion resulted by the replacement of least significant bit.Today ,I have done a program for creating bit planes of 24-bit color image.Here are input & output images of 24-bit color image:-


24-bit input image:-






24-bitplane output images:- 
Here we can see that bitplane of  24-bit image having more visible images than 8-bit & there is visible images for each RGB channels.




Tuesday, 15 January 2013

Terminology of BMP file format

Here we discuss some of terminology which are used in BMP file format.It is very important to having knowledge about them during study of BMP file format.They are following:-

Padding :-In Bmp file format each row in the pixel array must be in multiple of 4.If the image data row size is not in the multiple of 4 then it will make in multiple of 4 by adding to the each row. If each row in pixel array is in multiple of 4,then there is no need of padding.Row size is calculated with the help of Bits per pixel & image width in pixels which is following:-
                   
                 \mbox{RowSize} = \left\lfloor\frac { \mbox{BitsPerPixel} \cdot \mbox{ImageWidth}+31
 }{32}\right\rfloor \cdot 4,

Bits Per Pixel/Bit depth:- Bits per pixel or Bit depth are the same thing.It used to describe how many bits are stored in each pixel.With the help of bit depth we can know two things which are very important.First ,If image is of n bit per pixel it means it support 2^n distinct colors.For Example,If image is 8-bit per pixel then it supports 2^8=256 distinct colors.Second most important which we come to know is ,if image having n-bit per pixels it means n/8 byte occupies by 1 pixel because 8 bit=1 byte. Normally 1,2,4,8,12,16,24,30,32,36,48 bit depth images are possible.1 bpp is also called monochrome.Images of 15/16 bit color depth are called high color image.Image of 24-bit color depth is called true color image.There are 2^24 colors in the true color. 30,36 & 48 bit color depth image called deep color image .It used xvYCC,sRGB & YCbCr color spaces.Information of Bit depth stores on 28th byte of header & 14th byte of DIB header.Its information occupy 2 bytes.

Extra bit Masks:-It is found after DIB header.It is an optional structure in BMP image.Its main purpose is to define pixel formats.It has size of 3 or 4 DWORDs (12 or 16 bytes). This is only present when DIB header is BITMAPINFOHEADER.

BitMask:-In order to resolove the ambiguity of which bits define which samples,the dib header provide
certain defaults as well as specific BITFIELDS which are called bitmask that defines the particular group of bits in a pixel to a particular channel.

Alpha & Gamma :-There is many type of bitmasks available in DIB header.There is bitmask for all three channels R,G & B.There is an another bitmask which is called alpha channel bitmask.Alpha channel  is basically used as opacity channel.Alpha bitmask is avaliable after  66 bytes in header & occupy 4 bytes in DIB header.The alpha bitmask is valid whenever it is present in the DIB heder or when the compression member of DIB header is set to BI_ALPHABITFIELDS.
                                                                         Gamma is applicable for the all three channels RED,GREEN & BLUE.It is available in DIB header of a BMP image.It occupies 4-byte for each channel.If it is available in DIB header then It comes after 74 byte .

Some of more important details about BMP image are given below pointwise:-

1)Information of compression method used in image is available  after 30 byte of header .It is available in DIB header after 16 byte .Its occupies 4 bytes in header.

ValueIdentified byCompression methodComments
0BI_RGBnoneMost common
1BI_RLE8RLE 8-bit/pixelCan be used only with 8-bit/pixel bitmaps
2BI_RLE4RLE 4-bit/pixelCan be used only with 4-bit/pixel bitmaps
3BI_BITFIELDSBit field or Huffman 1D compression for BITMAPCOREHEADER2Pixel format defined by bit masks or Huffman 1D compressed bitmap for BITMAPCOREHEADER2
4BI_JPEGJPEG or RLE-24 compression for BITMAPCOREHEADER2The bitmap contains a JPEG image or RLE-24 compressed bitmap for BITMAPCOREHEADER2
5BI_PNGPNGThe bitmap contains a PNG image
6BI_ALPHABITFIELDSBit fieldThis value is valid in Windows CE .NET 4.0 and later.


2)BITMAPFILEHEADER is the first part of BMP image header.It has the information about Header field,file size,two reserved fields & an offset which is the starting address of image data.Its total size is 14 bytes .Header field is identification of BMP image .It has values like BM,BA,CM,CI etc. BITMAPFILEHEADER   also gives file size in bytes.It also have the reserved field each of size 2 bytes whose actual value depends on the  application   that creates the image.It also has information which stores information of starting address of  image data in bytes.this information occupy 4 bytes.

3)BITMAPCOREHEADER is the second part of BMP image header.It has the information about size of this structure,Width & height of image in pixels,no of color planes being used,no of bits per pixel in image.
It occupy  4 bytes for first 3 & occupy 2 bytes for last two.It means this structure total occupy 16 bytes.

4)BITMAPV5HEADER is an extended version of BITMAPINFOHEADER Structure.It has large information about image.It has extended information ARGB channel bitmask,Gamma for RGB channels
& Color space type,color space end points etc.

5)Size of color table entries is 3 bytes in BITMAPCOREHEADER & 4 bytes in BITMAPV5HEADER.

6)No of entries present in the Color table is found by 2^n where n is the bit depth or bits per pixel. Thus it is totally depend upon bit depth.Color table is mandatory for images which have bit depth of less than or equal to 8.  

7)The field colors in color table shows th no of colors in palette whose possible values 0 to default to 2^n where n is the bit depth.its information is stores on 46 th byte of header & its information size is 4 byte.

8)Number of important color count is availbale on 50th byte of header.Its information stores 4 byte of memory.It explain that how many important colors are used .0 means all colors are important.

9)The size of color space endpoints is 36 bytes .It comes after color space type in header. 74th byte is the offset for the color space points.

10)The 26th byte of header contains the information for how much color planes are used which must be set to 1.It occupy 2 bytes in header.

Color Space:-When the color model is associated with precise description of how the components are to be interpreted (viewing conditions etc.) the resulting set of colors is called Color Spaces.Possible values for color spaces are RGB,CMY/CMYK, YIQ,YPbPr,xvYCC,HSB,HSL,Munsell Color System,Natural Color System,RG chromaticity,TSL Color Space.70 byte is the offset for the color space type in header.Its inforamation size is 4 byte.
                                     RGB & CMYK color space are respectively additive & substractive color spaces they are descibed in previous blogs .Munsell & natural color systems are commercial color system.The RG chromaticity & TSL color Spaces are special purpose color spaces.The first one is used in computer vision application & the later is used for face detection.

*The two color Schemes widely used in bitmap compression are ARGB & AYCoCg.These schemes have the following color planes:-

Color scheme
Color planes
ARGB
Alpha, Red, Green, Blue
AYCoCg
Alpha, Luma, Orange Chroma, Green Chroma

Color Space Conversion:-Color channel based compression does not operate on the ARGB color space but rather a color space based on Luminosity (Y) & differential of two color components :Orange(Co)& Green(Cg).Conversion between ARGB & AYCoCg color spaces can be performed by using forward & inverse transformation.The Alpha channel is never converted in either direction.
The forward transformation to convert from ARGB to AYCoCg is as follows:-
A=A
|Y|=|1/4  1/2  1/4|       |R|
|Co|=|1    0     -1|   *  |G|
|Cg|=|-1/2  1  -1/2|     |B|
The inverse transformation to convert from AYCoCg to ARGB is as follows:-
A=A
|R|=|1 1/2 -1/2|     |Y|
|G|=|1 0 1/2 |     * |Co|
|B|=|1 -1/2 -1/2|   |Cg |
The allowed ranges of the individual color planes & their lengths in bits are as follows:-

Color plane
Range
Type
Alpha (A)
0 (transparent) – 255 (opaque)
8 bits
Red (R)
0 – 255
8 bits
Green (G)
0 – 255
8 bits
Blue (B)
0 – 255
8 bits
Luma (Y)
0 – 255
8 bits
Orange Chroma (Co)
-255 – 255
9 bits (two's complement)
Green Chroma (Cg)
-255 – 255
9 bits (two's complement)



Channel Separation

RGB Channel separation is the process in which we read the RGB channels separately.
Here is a input & output images for channel separation of three different type:-
1)First type is a simple channel separation in which we take R value for red channel,G value for green channel & B value for blue channel .For blue channel Blue put into the place of green & blue value for each pixel & then we get the blue channel separated image.This theory is applied respectively for red & green channel.

Input Image:-




Output Images:-

Red channel Image:-







Green Channel Image:-







Blue channel image:-








2)In second type of channel separation we take Blue value for blue channel,red value for red channel & green value for green channels & put 0 to the other value means we put 0 for red & green in blue channel.

here is the output images for same input image:-

 Output Images:-



Red channel Image:-       




Green Channel Image:-



Blue channel image:-


    



3)In third type of channel separation we create secondary colors from primary colors we use two of three to get a secondary colors.For Example we use blue & green color to create a cyan color image.Get a yellow                          color image with red & green .& magenta with red & blue colors.Here is the output images for  same input image.


Output Images:-

Magenta color Image:-



Cyan Color Image:-


Yellow Color Image:-





Friday, 11 January 2013

Edge Detection of a BMP Image Using Sobel Operator

Today ,I wrote a program for edge detection in Bitmap Image using Sobel Operator.Sobel operator is a descrete operator defined by Sobel.It has the horizontal & vertical derivative which has different values which are basically 3*3 matrix.These derivatives are convolved with image data  & Then produces edge detected image.First of all we should copy image data into an array.then this image data convolved with
horizontal & vertical derivatives.Here is the input & output images for the program :-

Input
Color Image
Output
Edge Detected Image
Here ,We need to discuss some more issues which occurred during programming which are following:-
1)We must take an unsigned char array for storing image data information.
2)Sobel Operator must stored in integer array because they have some negative values.
3)We should use abs function for calculating the gradient magnitude which is available in math.h header file.    

Tuesday, 8 January 2013

Histogram Equalization of a BMP image in C

Today i wrote a program for Histogram Equalization of a Bitmap Image in C.Histogram Equalization simply increases the contrast of images.Basically it balances the overall contrast of image.There is three basic steps in this program:First of all we should calculate probability distribution function of each pixel intensity,then we should calculate Cumulative Distribution function (CDF) of these intensity.Then we will calculate the equalized value on that intensity.
Here is the input & output image for the histogram equalization:-
Input Color Image 
Equalized Image

We have to be consider on some more topics on Histogram Equalization like:-
1)Disadvantages of He
2)When we should avoid He?
3)How can we overcome demerits of He?
4)Real world Application of He.

1)Disadvantage of He:-Followings are some disadvantages of He-
a)It reduces the brightness of some high contrast images.
b)If there are gray values which are physically far apart from each other in the image then this method fails.
c)This method is indiscriminate.It may increase the contrast of background noise & decrease the usable        
   signal.
d)Histogram equalization often produces unrealistic effects in photographs. 
e) It produces undesirable undesirable effects when applied low color depth image.

2)When we would emphasize on local contrast rather than overall contrast then we should avoid Histogram                    Equalization. 

3)We can overcome demerit of He using other generalized form of this like Adaptive histogram equalization (AHE) or Contrast limited adaptive histogram equalization(CLAHE).There are focus on local contrasts rather than overall contrast .they computes several histogram for this.

4)Here some real world application of He-:
a)It is very useful in scientific images like X-ray,thermal,Satellite.
b)It is also used in Biological Neural Network so as to maximize output firing rate of neuron .

Friday, 4 January 2013

Converting a Gray Scale To Black & white

Converting Gray Scale image Into Black & white is very simple .We should take the Each character & check if there is intensity greater than 128 then make it 255 while if it less than 128 then make it 0.Here is a input & output images for the Converting grayscale image into Black & white Image.



GrayScale Image

Black & white



Converting a Color Image To Gray Scale

A gray scale image is an image which has the same RGB values.It means R=G=B.We need to take a Color Image which has the different RGB values in a pixel.We take an average of RGB value & put it into RGB values of Output Image.Then we get  grayscaled image of input Image.

Color Image

Gray Scale Image
Here we discuss different methods to convert a 24-bit color image into gray scale image .In both of these methods there are some predefined constant which are multiplied to the RGB values of pixel to get a grayscale image for every pixel.These predefined values are some standard values diffrent for all three values
& multiplied into them to get a grayscale image.

1)
Y' =  0.299 R + 0.587 G + 0.114 B
2)
                                                Y' =  0.2126 R + 0.7152 G + 0.0722 B
3)                                            Y'=0.333(R+G+B)
4)                                            Y' =Max (R,G,B)

   In this type we calculate Maximum value among RGB value put it into the place of two other color's values.

5)                                             Y' =Min (R,G,B)

In this type we calculate Minimum value among RGB value put it into the place of two other color's values.

6)                                            Y'= (Max(R,G,B)+Min(R,G,B)) /2
 In this type we calculate both Max & min of RGB values .& Then average of them put into place of rgb values 

If Input image is same then output from various aalgorithm is here:-


.
The Last two images are respectively with Max & MIn algo.The Image with max algo is more brighter & The image with min algo is least brighter than other images.
Rest all four images are almost same in vision. 

Copying an Image

There is a two way to copy an Image :1. Copy an image character by character
2.The second is copy header of the Image then copy the data of the Image.We use both of the method in our programming .The functions for the these methods are given below:-