Friday, May 31, 2013

Image processing

Blurring:
A sharp point get smeared out into a disc shape is called blurring. In image terms, 

one pixel from the source image will spread over and mixed with the surrounding pixels. The operation need for this is called CONVOLUTION.
Working of convolution: imagine sliding a rectangular array of numbers over our image. This array is called the convolution kernel. For every pixel in the image, we take the corresponding numbers from the kernel and the pixels they are over, multiply them together and add all the results together to make the new pixel.

Basic idea
Using Sobel edge detection algorithm distributive image processing can be done. It has the property that the new pixel value is not only depending on the pixel’s original value, but also the value of the surrounding pixels. The image will be considered as a two dimensional array of pixels this image can be partitioned into subsets and operates in parallel by distributing subsets in various data tasks.


There are three steps:

  • Track each pixel inside the image excluding the edges.
  • Track the edges using the edge detection algorithm
  • Divide various splits in the image and do the above steps as various map tasks.

Convolution at a single pixel:


Consider a image with pixels at the fourth quadrant of 2D space. 


Let its length as hin x and y directions.  In x direction the pixels will be from 0 to m-1 and in y direction also the pixels will be from 0 to n-1.  


Place a kernel above the image. Its kernel coefficient will also be same as that of image pixels.


Compute the kernel half width


     M2= floor[m/2]
     N2=floor[n/2]

     Let sum=0, vary the values from –n to +n and  -m to +m.
       for(int k=-m2;k<=+m2;k++)
       for(int j=-n2;j<=+n2;j++)
     compute the sum value that is the pixel value that is obtained by computing the neighbouring pixel values and x and y coordinate values.
       sum= sum + h(j + m2, k + n2) f(x - j, y - k);
                g(x,y)=sum;

Convolution of the image using edge detection algorithm:

Consider the image with pixels at the fourth quadrant .Let its length as hin x and y directions.  In x direction the pixels will be from 0 to m-1 and in y direction also the pixels will be from 0 to n-1.  


Place a kernel above the image. Associate the kernel coefficient with the image pixels.


Compute the kernel half width


    M2= floor[m/2]
    N2=floor [n/2]
    Create an output image of size M*N.
    Assign zero to all pixel values.  g(x,y)=0
for y = n2 to N-n2-1 loop
for x = m2 to M-m2-1 loop
Compute g(x, y) using previous algorithm .The values including the edges will be computed.
Creating splits: Use getSplits
Dividing the splits into records: use getRecordReader
InputSplit
A chunk of the input that is processed by a single map.
RecordReader
An input split is divided into records, and the map processes each record (key-value pair) in turn. A RecordReader is used to generate record key-value pairs.

File input format
InputFormat describes the input-specification for a Map-Reduce job. Base class for all implementations of InputFormat that use files as their data source. Provides, methods to define which files are included as the input. The key value pair can be implemented as
lnputFormat<K,V> FilelnputFormat<K,V>.
Reuse the methods provided for defining which files are to be included as input to a job.
Define a filter to accept only certain image formats.
Define a custom implementation for generating splits for the input files.



















1 comment:

  1. Heya i'm for the primary time here. I came across this board and I find It really useful & it helped me out much. I'm hoping
    to give something back and aid others like
    you aided me.

    Here is my blog - getting perfect skin

    ReplyDelete