Tuesday, 19 February 2013

More about Image file format

Raster Image:-Raster images are actually a grid of pixel,each of which has a no of bits to designate its color equal to the color depth of device displaying it.It is also called bitmap images .In raster images image size is positively correlated to the no of pixel in an image the color depth & bits per pixel of the image. These are widely used in digital cameras ,scanners & laser printers.They are very popular in these days .Example of some Raster image file formats are JPEG,PNG,GIF ,TIFF,RAW & EXIF.

Vector Images:-Vector images can be any dimension dependent of file size.File size increases only with the addition of more vectors.Vector image format contain geometrical description which can be rendered smoothly at any desired display size.Vector images can be displayed with analog CRT technology such as that used in some electronic test equipment,medical monitor,radar displays ,laser shows & early video games.Plotters are also used vector data for draw graphics.Example of some Vector image file format are CGM,Gerber format & SVG.Some 2 D vector formats are AI,CDR,DrawingML etc.Vector images are not always appropriate in graphics work.

Generation Of Vector image:- Vector graphics is based on vectors (also called paths or strokes) which lead through locations called control points .Each of these points has a definite position on the x & y axes of the work plan.Each point ,as well is variety of database,including the location of the point in the work space & the direction of the vector.Each track can be assigned a color,a shape,a thickness & also a fill.This does not affect the size of the files in a substantial way because all information resides in the in the structure .

Difference between RGB & sRGB:-RGB color space is additive color space based on RGB color model.A particular RGB color space is defined by three chromatics of Red,Green & Blue additive color primaries.In this color space all colors produced are combination of these three primary colors.The complete specification of RGB color space also requires a white point chromacity & a Gamma correction curve.
                                 sRGB color space is standard RGB color space created cooperatively by HP & Microsoft in 1996 for use monitors ,printers & the internet.sRGB uses the ITU-R BT.709 primaries & transfer function Gamma curve .Unlike other RGB color spaces ,sRGB gamma cannot be represented as a single numerical value.sRGB color space has been endorsed by W3cC,Exif & Intel etc.The sRGB color space is well specified & designed to match typical home & office viewing condition. sRGB  color space is widely used in HDTV &  CRTs.




   

Monday, 18 February 2013

8-bit color Image

8-bit color image uses 1 byte for each pixel storage it means every pixel occupy 8-bit so it is called 8-bit image.The maximum no of color displayed at one time is 256 which is calculated through formula 2^n where n is bits per pixel.
                          Basically,there is two form of 8-bit color graphics .The most common uses a separate palette of 256 colors,where each of the 256 entries in the palette map to given red,green & blue values.In most color maps each color is chosen from a palette of 2^24 colors but in some cases, thecolor is chosen from palette of 2^12 or 2^18 colors.
                        The second form in which 8 bits directly describes the red ,green & blue component of pixel.The first 2 bytes is used for Blue ,next three bytes is used for green & last three byte of pixel is used for red.This form is sometime called 8-bit true color Because it does not uses palette at all.  

Terminology of Color Theory

There are some special terms which are widely used in color theory or in color processing.Some of them are explained here:-
1)Colorfulness:- Colorfulness is the degree of difference between a color & gray.
                         In other words "The attribute of a visual sensation according to which the perceived color of an area appears to be more or less chromatic ".

2)Chroma:-Chroma is the colorfulness relative to the brightness of another color that appears white under similar viewing conditions.
     In other words "the colorfulness relative to the brightness of a similarly illuminated white".
                   C= M-m

     where
                 M=Max(R,G,B)
                 m=min(R,G,B)


3)Saturation:-Saturation is the colorfulness of a color relative to its own brightness.Saturation for the HSV,HSL and HSI can be calculate by following formulas:-

\begin{align}
  S_{HSV} &=
    \begin{cases}
      0,           &\mbox{if } C = 0 \\
      \frac{C}{V}, &\mbox{otherwise}
    \end{cases} \\
  S_{HSL} &=
    \begin{cases}
      0,              &\mbox{if } C = 0 \\
      \frac{C}{1 - |2L - 1|},   &\mbox{otherwise}
    \end{cases}
\end{align}

S_{HSI} =
  \begin{cases}
    0,               &\mbox{if } C=0 \\
    1 - \frac{m}{I}, &\mbox{otherwise}
  \end{cases}
4)Lightness:-Lightness is a property of a color or a dimension of a color space that is defined in a way to reflect the subjective brightness perception of a color for humans along a lightness-darkness axis.
                            In other words "the brightness relative to the brightness of a similarly illuminated white."
In the HSL model lightness is defined by the average of largest and smallest color components.
                      L=1/2(M+m)
     where
                 M=Max(R,G,B)
                 m=min(R,G,B)

5)Brightness:-Brightness is an attribute of visual perception in which a source appears to be radiating or reflecting light.In the RGB color space ,brightness can be thought of as arithmetic mean of RGB value.
Brightness is also a color co-ordinates in HSB or HSV color space.It is denoted by B.It is also called value.
In other words "the attributes of a visual sensation according to which an area appears to omit more or less light".In the HSV color model value is defined as largest component of  color.
                               
                                    V = M

     where
                 M=Max(R,G,B)


6)Luma:-Luma represents the brightness in an image.This term is used in color video.Basically luma is the weighted sum of gamma compressed R'G'B' color components of color video.Luma is denoted by Y'.The prime symbol (') denotes gamma compression.For the Rec 709 primaries used in sRGB
                                 Y'709=0.21R+0.72G+0.07B
For the Rec. 601 NTSC primaries
                                 Y'601=0.30R+0.59G+0.11B
                         

7)Luminance:-Luminance is the photometric measure of the luminous intensity per unit area of light travelling in a given direction.It describes the amount of light that passes through or is omitted thruogh a particular area
& falls within a given solid angle.It is denoted by Y.The SI unit for luminance is candela/Square metre.Here is the formula for luminance:-

L_\mathrm{v} = \frac{\mathrm{d}^2 \Phi_\mathrm{v}}{\mathrm{d}A\,\mathrm{d}{\Omega} \cos \theta}



L_\mathrm{v} is the luminance (cd/m2),
\Phi_\mathrm{v} is the luminous flux or luminous power (lm),
\theta\, is the angle between the surface normal and the specified direction,
A is the area of the surface (m2), and
\Omega\, is the solid angle (sr).

8)Luminosity:-Luminosity is generally understood by measurement of brightness.It has SI unit joules per second which is called watt.Here is the formula for luminosity of a star:-


L = 4\pi R^2\sigma T^4 \,
where
σ is the Stefan–Boltzmann constant 5.67×10−8 W·m-2·K-4.

9)Hue:- Hue is one of the main properties of a color.It is also a color co-ordinates in HSV or HSB .The angle around the central vertical axis corresponds hue.A hue is the color element of color wheel.
                                          In other words "the attributes of visual sensation according to which an area appears to be similar to one of the perceived colors : red,yellow.green & blue or to a combination of two of them".
             The hue is the proportion of  the distance around the edge of the edge of the hexagon which passes through the projected point.Typically, it is measured in degrees and denoted by H.
\begin{align}
  H^\prime &=
    \begin{cases}
      \mathrm{undefined},        &\mbox{if } C = 0 \\
      \frac{G - B}{C} \;\bmod 6, &\mbox{if } M = R \\
      \frac{B - R}{C} + 2,       &\mbox{if } M = G \\
      \frac{R - G}{C} + 4,       &\mbox{if } M = B
    \end{cases} \\
  H        &= 60^\circ \times H^\prime
\end{align}


10)Contrast:-Contrast is the difference between the luminance and/or color that makes an object distinguishable.In visual perception of the real world ,contrast is determined by the difference in the color & brightness of the object & other objects within the same field of view.
                                      Contrast is also the difference between the color or shading of the printed material on a document & the background on which it is printed.Contrast is the ratio of luminance & average luminance. 
11)Intensity:-The total amount of light passing through a area is called intensity.It is denoted by I.It is also called radiance.In the HSI model intensity is the average of three color component:-
                                   
                                         I=1/3(R+G+B) 
       












Types Of Bitmap Header

There are six important type of file header which are given below:-

1)BITMAPFILEHEADER:-It has the first 14 bytes of any bitmap header.It has the following structure:-


struct bitmapHeader
   {
   char identity[2];//2bytes
            unsigned int sizeOfBmp,//4 bytes

            short int reserved,//2 bytes
 reserved1;//2 bytes
    unsigned int Startingadd;//4 bytes
}
This is the structure for the BITMAPFILEHEADER.In this structure identity is the char array which stores header field which is used to identify the bmp.Possible values are BM,BA,CI etc.Unsigned int sizeOfBmp shows the size of bmp file.Short int reserved & reserved1 are reserved value which actually depends upon  application that creates image.The last 4 bytes shows starting address of image data.

2)BITMAPCOREHEADER:-Its structure has five members


struct bitmapCoreHeader
   {
    unsigned int sizeOfDib,//4 bytes
                               widthinPixels,//4 bytes
                               heightinPixels;//4bytes
  short int noOfColorPlanes,//2 bytes
       BitsPerPixel;//2 bytes
}

It has some important information like width & height of BMP in pixels & bitdepth of bmp.

3) BITMAPINFOHEADER:-Its structure has 11 members.It is standard DIB header which we normally use in BMP file.It has total size of 40 bytes.


struct bitmapInfoHeader
   {
    unsigned int sizeOfDib,//4 bytes
                               widthinPixels,//4 bytes
                               heightinPixels;//4bytes
  short int noOfColorPlanes,//2 bytes
       BitsPerPixel;//2 bytes
           unsigned int compressionMethod,//4 bytes
                              imageSize,//4 bytes
                             horRes,//4 bytes
                             verRes,//4 bytes
                             noOfColorsInColorPalatte,//4 bytes
                            noOfImportantColorUsed;//4 bytes
}
It have some specific information like compression method used,horizontal & vertical resolution etc.

4)BITMAPV4HEADER:It has following structure:-

typedef struct {
  unsigned int bV4Size,//4 bytes
               bV4Width,//4 bytes
               bV4Height;// 4 bytes
  short int bV4Planes,//2 bytes
            bV4BitCount;//2 bytes
  unsigned int bV4V4Compression,//4 bytes
               bV4SizeImage,//4 bytes
               bV4XPelsPerMeter,//4 bytes
               bV4YPelsPerMeter,//4 bytes
               bV4ClrUsed,//4 bytes
               bV4ClrImportant,//4 bytes
               bV4RedMask,//4 bytes
               bV4GreenMask,//4 bytes
               bV4BlueMask,//4 bytes
               bV4AlphaMask,//4 bytes
               bV4CSType;//4 bytes
  CIEXYZTRIPLE bV4Endpoints;//36 bytes
  unsigned int bV4GammaRed,//4 bytes
               bV4GammaGreen,//4 bytes
               bV4GammaBlue;// 4 bytes
} BITMAPV4HEADER, *PBITMAPV4HEADER;
It has  Red,Green ,Blue & Alpha mask.4bytes for color space type.It also Gamma for all three RGB values

5))BITMAPV4HEADER:-It is the extended version of BITMAPINFOHEADER.It has following structure:-

typedef struct {
  unsigned int bV5Size,//4 bytes
               bV5Width,//4 bytes
               bV5Height;// 4 bytes
  short int bV5Planes,//2 bytes
            bV5BitCount;//2 bytes
  unsigned int bV5V4Compression,//4 bytes
               bV5SizeImage,//4 bytes
               bV5XPelsPerMeter,//4 bytes
               bV5YPelsPerMeter,//4 bytes
               bV5ClrUsed,//4 bytes
               bV5ClrImportant,//4 bytes
               bV5RedMask,//4 bytes
               bV5GreenMask,//4 bytes
               bV5BlueMask,//4 bytes
               bV5AlphaMask,//4 bytes
               bV5CSType;//4 bytes
  CIEXYZTRIPLE bV5Endpoints;//36 bytes
  unsigned int bV5GammaRed,//4 bytes
               bV5GammaGreen,//4 bytes
               bV5GammaBlue,// 4 bytes
               bV5Intent,// 4 bytes
               bV5ProfileData,// 4 bytes
              bV5ProfileSize,// 4 bytes
              bV5Reserved;// 4 bytes
} BITMAPV5HEADER, *PBITMAPV5HEADER;



Sunday, 17 February 2013

Color Co-ordinates

Color Co-ordinates ranges are a matter of designer choice & there is no universal standard range for many color space.There are different type of color co-ordinates which are explained below:-

1)Hex Triplet
2)sRGB
3)CMYK
4)HSV

1)Hex Triplet:- Hex triplet is a six digit three byte hexadecimal number used in HTML,CSS & SVG and other computing applications to represent colors.The bytes represent red ,green & blue color component.The one byte represent number from 00 to FF (in hexadecimal) & 0 to 255 (in decimal).The hex triplet is formed by concatenating  three bytes in following order:-
Byte 1:red value (color type red)
Byte 2:green value(color type green)
Byte 3:blue value(color type blue)

If the values of red ,green & blue component is respectively 36,104 & 160.Then these are represented by 24,68 & A0 in hexadecimal notation.So hex triplet is obtained by concatenating 6 hexadecimal digit & in this case it will be 2468A0.If any one of these three color values are less than 10 in hex.Then it must be represented with a leading 0 because hex triplet exactly have a six digit number.

2)sRGB:-sRGB is a standard color space created by HP & Microsoft co-operatively.It is used in monitors ,printers & internet.The sRGB color space is well specified & is designed to match home & office view conditions.LCDs ,Digital Cameras & Scanners & printers all follow the RGB  color space.
sRGB also defines a non-linear transformation between the intensity of these primaries.
ChromaticityRedGreenBlueWhite point
x0.64000.30000.15000.3127
y0.33000.60000.06000.3290
Y0.21260.71530.07211.0000







3)CMYK:-It is also called substractive color model .It is used in color printing.If we mix green & blue color in equal proportion then we get Cyan color .If we mix red & blue color in equal proportion then we get magenta & if we combine Red & Green in equal proportion then we get yellow color . K in CMYK used as key color .It is also said that it is used for last letter in black.Because b is already used for blue.

4)HSV:- HSV is used for hue,saturation & value.It is also known as HSB where B is used for brightness.HSV is basically used in computer vision & image analysis for feature detection or image analysis.
The main disadvantage of HSV is it choose a single color & ignore much off complexity of color appearance.
                       


*For calculating no of entries in color table we can use formula 2 ^n where n is the bit depth.So ,it is directly depend on bit-depth.

* General formula for calculating starting address of image data is here:-

           Sa=(Size of header + Size of Color Table)
           
For More than 8-bit depth

Sa=Size of header

Because there is no color table in image of more than 8-bit depth.

For =<8 bit depth,

Sa=(Size of header+(4*no of possible colors)
    =(Size of header +(4*2^n))

where n is bit depth of image.

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:-