Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
MORPHOLOGICAL BACKGROUND DETECTION &     ENHANCEMENT OF IMAGES WITH POOR LIGHTINGAn industry Oriented Mini Project submitt...
CERTIFICATE                              This is to certify that K.Sindhu(07AJ1A0444), G.V.Charantej(07AJ1A0412), M.Sriniv...
ACKNOWLEDGEMENTS      We would like to express our deepest gratitude to Dr. P. V. SUBBAIAH            Principal,Amrita Sai...
CONTENTS ABSTRACT1. INTRODUCTION  1.1 Morphology  1.2 Morphological Transformations2. PROPOSED METHOD  2.1   Background de...
ABSTRACT:       In this project, some morphological transformations are used to detect the background inimages characteriz...
1. INTRODUCTION                        The world is filled with images, which are representations of objects andscenes in ...
intensities are reordered within the image to obtain a uniform distributed histogram. However,the main disadvantage of his...
structuring element (also known as a kernel). It is this structuring element that determines theprecise effect of the eros...
2. PROPOSED METHOD       In this project there are two approximations to compute the backgrounds in the processedimages ar...
In the 1-D case, as illustrated in Fig, the following expression is obtained:                  Fig. 2.1.2: Background crit...
this image and the corresponding pixel in original image. Combine them using Weber’s lawwhich can be stated as follows. Th...
Morphological operations:               In a morphological operation, the value of each pixel in the output image is based...
Erosion:             Erosion is one of the two basic operators in the area of mathematical morphology,the other being dila...
2.3 Structuring Elements:                        An essential part of the dilation and erosion operations is the structuri...
calculation. We must use the STRELgetnhood method to retrieve the neighborhood of thestructuring element from the STREL ob...
Histogram equalization often produces unrealistic effects in photographs;however it is very useful for scientific images l...
3.CODINGMain:clcclear allclose all[file path]=uigetfile(*.jpg);I=imread([path file]);eqn10(I); % IMAGE BACKGROUND APPROXIM...
imshow(I,[]);title(Original Image);subplot(1,2,2)imshow(I1,[]);title(Enhanced Image: Eqn 10);% Histogramfigure,subplot(1,2...
mm=m;       else         mm=M;       end       k=(255-mm)/log(256);       if f<=t         BB(i,j)=k*log(f+1)+M;       else...
subplot(1,2,2)imshow(I1,[]);title(eqn13 Image)% Histogramfigure,subplot(1,2,1),imhist(uint8(I))title(INPUT IMAGE)axis([0 2...
if f<=t        I1(i,j)=k*log2(f+1)+d;      else        I1(i,j)=k*log2(f+1)+e;      end  endendHistogram eqn:function histo...
4. RESULT & CONCLUSION              This project presents a study to detect the image background and to enhance thecontras...
23
Upcoming SlideShare
Loading in …5
×

Morpho

2,630 views

Published on

Published in: Education

Morpho

  1. 1. MORPHOLOGICAL BACKGROUND DETECTION & ENHANCEMENT OF IMAGES WITH POOR LIGHTINGAn industry Oriented Mini Project submitted to the Jawaharlal Nehru Technology University inpartial fulfillment of the requirements for the award of the Degree of BACHELOR OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION AND ENGINEERING Submitted By K.Sindhu G.V.Charan Tej M.Srinivasulu 07AJ1A0444 07AJ1A0412 07AJ1A0423DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING AMRITA SAI INSTITUTE OF SCIENCE AND TECHNOLOGY (APPROVED BY AICTE, NEW DELHI; AFFILIATED TO JNTU, KAKINADA) PARITALA, KRISHNA DISTRICT – 521 180 (A. P.) NOV-DEC 2010 1
  2. 2. CERTIFICATE This is to certify that K.Sindhu(07AJ1A0444), G.V.Charantej(07AJ1A0412), M.Srinivasulu(07AJ1A0423) Students of B.Tech (Electronics AndCommunication Engineering) IV-I Semester have successfully completed their project work,titled “MORPHOLOGICAL BACKGROUND DETECTION & ENHANCEMENT OFIMAGES WITH POOR LIGHTING” at AMRITA SAI INSTITUTE OF SCIENCE ANDTECHNOLOGY during the Academic year 2009-2010. This is submitted as a partial fulfillmentfor the award of the Degree B.Tech( Electronics And Communication Engineering) and is notsubmitted else where. Head of the Department (Mr.B.RamaRao) 2
  3. 3. ACKNOWLEDGEMENTS We would like to express our deepest gratitude to Dr. P. V. SUBBAIAH Principal,Amrita Sai Institute of science and Technology. We are grateful to the Head of the Department of ECE Mr.B.RamaRao, under thesupervision of their assistance and encouragement in carrying out the project. We sincerely thank all the faculty and staff members of the Department of ECE for theirkind co-operation. Finally we thank one and all who directly or indirectly helped us to complete ourmini project successfully. Yours Sincerely, K.Sindhu G.V.Charan tej M.Srinivasulu 3
  4. 4. CONTENTS ABSTRACT1. INTRODUCTION 1.1 Morphology 1.2 Morphological Transformations2. PROPOSED METHOD 2.1 Background detection by block analysis 2.2 Background detection using morphological operations 2.3 Structuring element 2.4 Histogram equalization3. CODING4. RESULT & CONCLUSION 4
  5. 5. ABSTRACT: In this project, some morphological transformations are used to detect the background inimages characterized by poor lighting. Lately, contrast image enhancement has been carried outby the application of two operators based on the Weber’s law notion. The first operator employsinformation from block analysis, while the second transformation utilizes the opening byreconstruction, which is employed to define the multi background notion. When we are taking the image, the flash will fall on the target and reflects back to thelens. Then the monochrome image will be formed. The image may be dark or poor lightening.Due poor lightening the background of the image is not clear. This image can be enhanced bylightening the back ground. It employs the division of whole image of into several blocks. Eachblock consists of pixels. Find out the minimum and the maximum values of the pixels in thatblock. Calculate the average value of the pixel. Now change the values of the remaining pixels inthe block to the average value. We do the same process for the remaining blocks also. Then theenhanced image is formed. Consider the each pixel in the original image in enhanced image andcorresponding pixel in original image and thus combine these pixels using Weber’s law. Thus areconstructed image is obtained. In this way the background lightening can be enhanced. 5
  6. 6. 1. INTRODUCTION The world is filled with images, which are representations of objects andscenes in the real world. Images are represented by an array of pixels, which can represent thegray levels or colors of the image. There are many aspects of images that are ambiguous anduncertain. Examples of these vague aspects include determining the border of a blurred objectand determining which gray values of pixels are bright and which are dark Sometimes an imagemay be too dark contains blurriness and therefore difficult to recognize the different objects orscenery contained in the image. Image enhancement algorithms are applied to remotely senseddata to improve the appearance of an image for human visual analysis or occasionally forsubsequent machine analysis. The objective of image enhancement is dependent on theapplication context; criteria for enhancement are often subjective or too complex to be easilyconverted to useful objective measures. Image enhancement techniques are widely used in manyfields, where the subjective quality of images is important. Many algorithms for achievingcontrast enhancement have been developed. Those enhancement algorithms can be classified intotwo types point operations, which are global and spatial neighborhood techniques, which arelocal. In this work, two methodologies to compute the image background areproposed. Also, some operators to enhance and normalize the contrast in grey level images withpoor lighting are introduced. Contrast operators are based on the logarithm function in a similarway to Weber’s law. The use of the logarithm function avoids abrupt changes in lighting. Also,two approximations to compute the background in the processed images are proposed using Matlab Simulink. The first proposal consists in an analysis by blocks, whereas in the secondproposal, the opening by reconstruction. Even though morphological contrast has been largely studied, there are nomethodologies, from the point of view MM, capable of simultaneously normalizing andenhancing the contrast in images with poor lighting. On the other side, one of the most commontechniques in image processing to enhance dark regions is the use of nonlinear functions, such aslogarithm or power functions ; otherwise, a method that works in the frequency domain is thehomomorphic filter . In addition, there are techniques based on data statistical analysis, such asglobal and local histogram equalization. During the histogram equalization process, grey level 6
  7. 7. intensities are reordered within the image to obtain a uniform distributed histogram. However,the main disadvantage of histogram equalization is that the global properties of the image cannotbe properly applied in a local context, frequently producing a poor performance in detailpreservation. In, a method to enhance contrast is proposed; the methodology consists in solvingan optimization problem that maximizes the average local contrast of an image.1.1 Morphology: Morphology is a technique of image processing based on shapes. The value of each pixelin the output image is based on a comparison of the corresponding pixel in the input image withits neighbors. By choosing the size and shape of the neighborhood, you can construct amorphological operation that is sensitive to specific shapes in the input image. Mathematical morphology is a set-theoretical approach to multi-dimensional digitalsignal or image analysis, based on shape. It is a theory and technique for the analysis andprocessing of geometrical structures, based on set theory, lattice theory, topology, and randomfunctions. It is most commonly applied to digital images, but it can be employed as well ongraphs, surface meshes, solids, and many other spatial structures. It is also the foundation of morphological image processing, which consists of a set ofoperators that transform images according to the above characterizations. Mathematical morphology was originally developed for binary images, and was laterextended to scale functions and images. The subsequent generalization to complete lattices iswidely accepted today as MMs theoretical foundation.1.2 Morphological transformations: Basically morphological transformations such as erosion, dilation, opening & closingare used to detect the background.Erosion: Erosion is one of the two basic operators in the area of mathematical morphology, theother being dilation. It is typically applied to binary images, but there are versions that work ongray scale images. The erosion operator takes two pieces of data as inputs. The first is the imagewhich is to be eroded. The second is a (usually small) set of coordinate points known as a 7
  8. 8. structuring element (also known as a kernel). It is this structuring element that determines theprecise effect of the erosion on the input image. In erosion, every object pixel that is touching abackground pixel is changed into a background pixel. Gray scale erosion with a flat disk shaped structuring element will generallydarken the image. Bright regions surrounded by dark regions shrink in size, and dark regionssurrounded by bright regions grow in size. Small bright spots in images will disappear as theyare eroded away down to the surrounding intensity value, and small dark spots will becomelarger spots. The effect is most marked at places in the image where the intensity changesrapidly, and regions of fairly uniform intensity will be left more or less unchanged except at theiredges.Dilation: Dilation adds pixels to the boundaries of objects in an image. Indilation, every background pixel that is touching an object pixel is changed into an object pixel.Note how the function applies the rule to the input pixels neighborhood and uses the highestvalue of all the pixels in the neighborhood as the value of the corresponding pixel in the outputimage. 8
  9. 9. 2. PROPOSED METHOD In this project there are two approximations to compute the backgrounds in the processedimages are proposed using Matlab simulink. The first proposal consists in an analysis by blocks,whereas in the second proposal, morphological operators are used.2.1 Background Detection by Block Analysis: In this analysis, first of all we will read an image as input image and divide it into severalblocks and from each block we will determine the background and apply the weber’s law andthereby we obtain an enhanced image Fig. 2.1.1 Block diagram of Background Detection by Block Analysis Let us consider an image which is to be enhanced. The image is divided into nblocks of size. Each block is a sub image of the original image. As the image is made up ofnumber of pixels each block consists of number of pixels. Find the maximum and minimumintensity values of pixels of each block. For each analyzed block, maximum (Mi) and minimum (mi) values are used todetermine the background criteria Ti in the following way: 9
  10. 10. In the 1-D case, as illustrated in Fig, the following expression is obtained: Fig. 2.1.2: Background criteria obtained by block analysis. Once Ti is calculated, this value is used to select the background parameterassociated with the analyzed block. As follows, an expression to enhance the contrast isproposed: Note that the background parameter depends on the Ti value. If f<=Ti(dark region), the background parameter takes the value of the maximum intensity(Mi) withinthe analyzed block, and the minimum intensity(mi) value otherwise. Also, the unit was added tothe logarithm function in above equation to avoid indetermination. On the other hand, since greylevel images are used in this work, the constant Ki in above equation is obtained as follows: On the other hand, M i. and mi values are used as background parameters toimprove the contrast depending on the Ti value, due to the background is different for clear anddark regions. Now an image is formed by applying the above equation. Now consider a pixel in 10
  11. 11. this image and the corresponding pixel in original image. Combine them using Weber’s lawwhich can be stated as follows. Thus an enhanced image is formed.Weber’s Law: In psycho-visual studies, the contrast C of an object with luminance Lmax against itssurrounding luminance Lmin is defined as follows If L=Lmin and =Lmax-Lmin so it can be written as followsIn the above Equation indicates that(log L) is proportional to C. Therefore, Weber’s law can beexpressed as Where k and b are constants, b being the background. In this case, an approximationto Weber’s law is considered by taking the luminance L as the grey level intensity of a function(image); in this way, above expression is written as follows2.2 Background detection using morphological operators: On the other hand, given that, maximum and minimum values areanalyzed for each block, an extension using morphological operators is presented as follows. Fig. 2.2 Block diagram of Background Detection by Erosion & Dilation 11
  12. 12. Morphological operations: In a morphological operation, the value of each pixel in the output image is basedon a comparison of the corresponding pixel in the input image with its neighbors. By choosingthe size and shape of the neighborhood, you can construct a morphological operation that issensitive to specific shapes in the input image. Dilation and erosion are two fundamentalmorphological operations. Dilation adds pixels to the boundaries of objects in an image, whileerosion removes pixels on object boundaries. The number of pixels added or removed from theobjects in an image depends on the size and shape of the structuring element used to process theimage. In the morphological dilation and erosion operations, the state of any given pixel in theoutput image is determined by applying a rule to the corresponding pixel and its neighbors in theinput image. The rule used to process the pixels defines the operation as a dilation or an erosion.Rules for Dilation and Erosion:Operation RuleDilation The value of the output pixel is the maximum value of all the pixels in the input pixels neighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixel is set to 1. The value of the output pixel is the minimum value of all the pixels in the inputErosion pixels neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set to 0. 12
  13. 13. Erosion: Erosion is one of the two basic operators in the area of mathematical morphology,the other being dilation. It is typically applied to binary images, but there are versions that workon gray scale images. The erosion operator takes two pieces of data as inputs. The first is theimage which is to be eroded. The second is a (usually small) set of coordinate points known as astructuring element (also known as a kernel). It is this structuring element that determines theprecise effect of the erosion on the input image. In erosion, every object pixel that is touching abackground pixel is changed into a background pixel.Dilation: Dilation adds pixels to the boundaries of objects in an image. In dilation, everybackground pixel that is touching an object pixel is changed into an object pixel. Note how thefunction applies the rule to the input pixels neighborhood and uses the highest value of all thepixels in the neighborhood as the value of the corresponding pixel in the output image. Let Imax(x) and Imin(x) be the maximum and minimum intensity values taken fromone set of pixels contained in a window (B) of elemental size (3 X 3 elements), x belongs to D.Notice that the window corresponds to the structuring element .A new expression can be derivedas shown: Where Imax(x) and Imin(x) values correspond to the morphological dilationand erosion defined by the order-statistical filters. Thus, the above expression is expressed asFinally the proposed transformation is expressed as 13
  14. 14. 2.3 Structuring Elements: An essential part of the dilation and erosion operations is the structuringelement used to probe the input image. A structuring element is a matrix consisting of only 0sand 1s that can have any arbitrary shape and size. The pixels with values of 1 define theneighborhood. Two-dimensional, or flat, structuring elements are typically much smaller thanthe image being processed. The center pixel of the structuring element, called the origin,identifies the pixel of interest -- the pixel being processed. The pixels in the structuring elementcontaining 1s define the neighborhood of the structuring element. These pixels are alsoconsidered in dilation or erosion processing. Three-dimensional, or nonflat, structuring elements use 0s and 1s to definethe extent of the structuring element in the x- and y-planes and add height values to define thethird dimension. Origin of a Structuring Element: The morphological functions use this code to get the coordinates of theorigin of structuring elements of any size and dimension Origin = floor ((size (nhood) +1)/2) (1) Here nhood is the neighborhood defining the structuring element. Because structuringelements are MATLAB objects, we cannot use the size of the STREL object itself in this 14
  15. 15. calculation. We must use the STRELgetnhood method to retrieve the neighborhood of thestructuring element from the STREL object.For example, the following illustrates a diamond-shaped structuring element Fig. 4.3 a diamond-shaped structuring elemen Creating a Structuring Element: The toolbox dilation and erosion functions accept structuring elementobjects, called STRELs. We use the strel function to create STRELs of any arbitrary size andshape. The strel function also includes built-in support for many common shapes, such as lines,diamonds, disks, periodic lines, and balls.For example, this code creates a flat, diamond-shaped structuring element. se = strel (diamond, 3). where 3 specifies the distance from the structuring element origin to the pointsof the diamond.2.4 Histogram Equalization: Histogram equalization is a method in imageprocessing of contrastadjustment using the imageshistogram. This method usually increases the global contrast ofmany images, especially when the usable data of the image is represented by close contrastvalues. Through this adjustment, the intensities can be better distributed on the histogram. Thisallows for areas of lower local contrast to gain a higher contrast without affecting the globalcontrast. Histogram equalization accomplishes this by effectively spreading out the mostfrequent intensity values. The method is useful in images with backgrounds and foregrounds thatare both bright or both dark. In particular, the method can lead to better views of bone structurein x-ray images, and to better detail in photographs that are over or under-exposed. 15
  16. 16. Histogram equalization often produces unrealistic effects in photographs;however it is very useful for scientific images like thermal, satellite or x-ray images, often thesame class of images that user would apply false-color to. Also histogram equalization canproduce undesirable effects (like visible image gradient) when applied to images with low colordepth. Figure shows that for any given mapping function y=f(x) between theinput and output Images, the following holds p(y) dy=p(x) dxi.ie., the number of pixels mappedfrom x to y is unchanged. 16
  17. 17. 3.CODINGMain:clcclear allclose all[file path]=uigetfile(*.jpg);I=imread([path file]);eqn10(I); % IMAGE BACKGROUND APPROXIMATION BY BLOCKSeqn13(I);% histogram_eq(I); % HISTOGRAM EQUALIZATIONEqn10:function eqn10(I)figure,imshow(I);title(Original Image);I=imresize(I,[256 256]);I=rgb2gray(I);I=double(I);xw=8;for i=1:size(I,1)/xw for j=1:size(I,2)/xw B=I(((i-1)*xw)+1:i*xw,(((j-1)*xw))+1:j*xw); m=min(min(B))/255; M=max(max(B))/255; t=(m+M)/2; BB=blockkk(m,M,t,B,xw); I1(((i-1)*xw)+1:i*xw,(((j-1)*xw))+1:j*xw)=BB; endendfigure,subplot(1,2,1) 17
  18. 18. imshow(I,[]);title(Original Image);subplot(1,2,2)imshow(I1,[]);title(Enhanced Image: Eqn 10);% Histogramfigure,subplot(1,2,1),imhist(uint8(I))title(INPUT IMAGE)axis([0 255 0 8000])subplot(1,2,2),imhist(uint8(I1))title(IMAGE EQN10)axis([0 255 0 8000])% Disply Graphfigure,plot(I(25,:),r),hold onplot(I1(size(I,1)/2,:),g)% axis([0 255 0 260])legend(Input Image,Out put Image)xlabel(Intensity level)ylabel(Image Values)title(IMAGE BACKGROUND APPROXIMATION BY BLOCKS EQN10)function BB=blockkk(m,M,t,B,xw)BB=zeros(xw);for i=1:xw for j=1:xw f=B(i,j); if f > t 18
  19. 19. mm=m; else mm=M; end k=(255-mm)/log(256); if f<=t BB(i,j)=k*log(f+1)+M; else BB(i,j)=k*log(f+1)+m; end endendEqn13:function eqn13(I)I=imresize(I,[256 256]);I=rgb2gray(I);I=double(I);u=1;radious=2*u+1;se=strel(square,radious);xw=8;for i=1:size(I,1)/xw for j=1:size(I,2)/xw B=I(((i-1)*xw)+1:i*xw,(((j-1)*xw))+1:j*xw); BB=formula(B,se); I1(((i-1)*xw)+1:i*xw,(((j-1)*xw))+1:j*xw)=BB; endendfigure,subplot(1,2,1)imshow(I,[]),title(Original Image) 19
  20. 20. subplot(1,2,2)imshow(I1,[]);title(eqn13 Image)% Histogramfigure,subplot(1,2,1),imhist(uint8(I))title(INPUT IMAGE)axis([0 255 0 8000])subplot(1,2,2),imhist(uint8(I1))title(IMAGE EQN13)axis([0 255 0 8000])% Disply Graphfigure,plot(I(size(I,1)/2,:),r),hold onplot(I1(size(I,1)/2,:),g),axis([0 255 0 260])legend(Input Image,Out put Image)xlabel(Intensity level)ylabel(Image Values)title(IMAGE BACKGROUND APPROXIMATION BY BLOCKS EQN13)function I1=formula(I,se)I1=zeros(size(I,1));E=imerode(I,se);D=imdilate(I,se);for i=1:size(I,1) for j=1:size(I,2) e=E(i,j); d=D(i,j); f=I(i,j); t=(e+d)/2; k=(255-t)/log(256); 20
  21. 21. if f<=t I1(i,j)=k*log2(f+1)+d; else I1(i,j)=k*log2(f+1)+e; end endendHistogram eqn:function histogram_eq(I)I=imresize(I,[256 256]);I=rgb2gray(I);I1=histeq(I);figure,subplot(1,2,1)imshow(I,[]),title(Original Image)subplot(1,2,2)imshow(I1,[]),title(Histogram Equalization)% Histogramfigure, subplot(1,2,1),imhist(uint8(I))title(INPUT IMAGE)axis([0 255 0 8000])subplot(1,2,2),imhist(uint8(I1))title(HIST EQUAIZATION)axis([0 255 0 8000])% Disply Graphfigure,plot(I(size(I,1)/2,:),r),hold onplot(I1(size(I,1)/2,:),g),axis([0 255 0 260])legend(Input Image,Out put Image)xlabel(Intensity level)ylabel(Image Values)title(HISTOGRAM EQUALIZATION) 21
  22. 22. 4. RESULT & CONCLUSION This project presents a study to detect the image background and to enhance thecontrast in binary images with poor lighting. First, a methodology was introduced to computean approximation to the background using blocks analysis. This proposal was subsequentlyextended using mathematical morphology operators. Let us consider the input image as shown in fig (a) and the obtainedenhanced image which is shown in the fig (b) Fig (a) Original image Fig (b) Enhanced image 22
  23. 23. 23

×