Home
Image Processing with LabVIEW and IMAQ Vision
Contents
1. A B 3 Minimum Value D 000000 4 Maximum Value 249 000 000 pixels 5 Starting Value 0 000000 B Interval Width 1 000 000 495 7 Mean Value 96 508 559 8 Standard Deviation 49 595 001 1200 9 Area pixels 75 840 000 000 1000 10 800 11 Intensity Pixels 12 5 600 13 1 400 14 2 200 15 3 0 16 4 0 50 100 150 200 250 le 5 18 6 4n 7T Figure 4 3 Histogram Exported in MS Excel IM National Instruments File Image Golor Gi ale Binary Machine Vision Script Help x amp amp vme i e uw ba o D o e Hilva Die P 3 20 Toler 8 alam By 316240171 4 EU Script E ES Histogram Mapping mode Linear Color Model RGB Logarithmic Red SNS ESS Help Green NS 5 e wie Cl pelele Seu UE n Ww uw eur Be ANA fa ce D 2 50 75 100 125 150 175 200 225 255 Figure 4 4 Color Histogram Function in IMAQ Vision Builder 4 Image Processing 155 Sout x y f Sin x y 4 2 with sin as the original values and sout as the resulting values Because the possible results are limited to 256 values the function f g usually is realized by a table consisting of 256 values a look up table LuT Therefore if LuT g f g 4 3 Eq 4 2 will change to Sout y LuT sin z y 4 4 Special LuTs Math Functions The easiest way to generate a LuT is to use mathematic
2. 2 0 2 are called Sobel filters or Sobel kernels A Sobel 1 01 kernel gives the specified filter direction a stronger weight In general the mathematic value gradient specifies the amount of change of a value in a certain direction The simplest filter kernels used in two orthog onal directions are 4 Image Processing 173 a exercise 4 7 6 filtered Image i r P t x V x Ne Ax UY i Ret File Edit Operate Tools Browse Window Help on Kernel Family a Gradient 1 Kernel Number jj 1 Kernel Size 3 3 Predefined x fo Figure 4 26 Filter Example Gradient 1 NUN EN Predefined vX fo Figure 4 27 Filter Example Gradient 4 174 IMAGE Processing with LabVIEW and IMAQ Vision F and E ccc 0 1 1 oo 0 i s 4 16 0 resulting in two images Ty s x y and tion of the gradient are therefore y Sy x y Value and direc Sa x y s 4 17 Filter Families Laplacian All kernels of the Laplacian filter group are omnidirectional that means they provide edge information in each direction Like the Laplacian operator in mathematics the Laplacian kernels are of a second order derivative type and show two interesting effects se a y sy y and tang m Ifthe sum of all coefficients is equal to 0 the filter kernel shows all image areas with a significant brightness change that means it works as an omnidirectional edge
3. Figure 4 36 FFT Low Pass Filter The inverse fast Fourier transform FFT used in Exercise 4 9 and in the function IMAQ InverseFFT is calculated as follows 4 Image Processing 181 IE exercise 4 9 vi Diagram lol xl File Edit Operate Tools Browse Window Help runcation Frequency Figure 4 37 Diagram of Exercise 4 9 zig xi s m 5 5 S u v eX 4 21 182 IMAGE Processing with LabVIEW and IMAQ Vision FFT Filtering Attenuate An attenuation filter applies a linear attenuation to the full frequency range In a low pass attenuation filter each frequency f from fo to fmax is multiplied by a coefficient C which is a function of f according to Ue mee 4 22 e fmax fo It is easy to modify Exercise 4 9 to a VI that performs attenuation filtering Exercise 4 10 Attenuation Filtering Replace the IMAQ Vision function IMAQ Com plexTruncate with IMAQ ComplexAttenuate and watch the results see Figure 4 39 Note that the high pass setting obviously returns a black image is that true The formula for the coefficient C in a high pass attenuation filter is f fo eu fmax fo i ere which means that only high frequencies are multiplied by a significantly high coefficient C f Therefore the high pass result of Exercise 4 10 Figure 4 40 contains a number of frequencies that are not yet visible You may insert the LuT function IMAQ Equalize
4. closing Z erosion dilation Z 4 47 Gray Level Proper Opening and Proper Closing The two gray level functions proper opening and proper closing are a little bit different from their 220 IMAGE Processing with LabVIEW and IMAQ Vision i exercise 4 21 E 1 i Gray Morphology Open Figure 4 88 Gray Morphology Closing binary versions According to 4 gray level proper opening is used to remove bright pixels in a dark surrounding and to smooth surfaces the function is described by proper opening Z min Z opening closing opening Z 4 48 note that the AND function of the binary version is replaced by a minimum function A result is shown in Figure 4 89 The gray level proper closing function is defined as proper closing Z max Z closing opening closing Z 449 a result is shown in Figure 4 90 4 Image Processing 221 IE exercise 4 21 ib Gray Morphology PClose loj x r i Figure 4 90 Gray Morphology Proper Closing Auto Median Function Compared to the binary version the gray level auto median function also produces images with fewer details The definition is different the gray level auto median calculates the minimum value of two temporary images both resulting from combinations of gray level opening and closing functions automedian Z min opening closing opening 1 4 50 closing opening closing Z 222 IMAGE Processing with LabVIEW and IMAQ Vision See Figure 4
5. Interval i Figure 4 70 Particle Filtering by x Coordinate m Ratio area scanned area Percentage of the surface area of a particle in relation to the scanned area m Ratio area total area Percentage of particle surface in relation to the total area m Center of mass X x coordinate of the center of gravity m Center of mass Y y coordinate of the center of gravity m Left column X Left x coordinate of bounding rectangle m Upper row Y Top y coordinate of bounding rectangle m Right column X Right x coordinate of bounding rectangle m Lower row Y Bottom y coordinate of bounding rectangle 4 Image Processing 207 iix exercise 4 16 vi Diagram File Edit Operate Tools Browse Window Help Em 5 8 e n e bal ot 13pt Application Font tor Tar Figure 4 71 Diagram of Exercise 4 16 Width Width of bounding rectangle in user units Height Height of bounding rectangle in user units Longest segment length Length of longest horizontal line segment Longest segment left column X Leftmost x coordinate of longest hori zontal line segment Longest segment row Y y coordinate of longest horizontal line segment Perimeter Length of outer contour of particle in user units Hole perimeter Perimeter of all holes in user units SumxX Sum of the x axis for each pixel of the particle SumY Sum of the y axis for each pixel of the particle SumXX Sum
6. Lookup Table 255 200 1 1 1 1 1 50 100 150 200 255 Original Figure 4 9 Creating a Square Look up Table 255 Sout z y Sin x y V255 Sin x y 16 4 8 The next two cases need an additional factor called power value p We cre ate the function 255 1 Sout 2 Y sin 09 5s sin 0 ze DEED 4 9 IMAQO Vision calls this function power z its realization can be seen in Figure 4 11 for a power value of p 3 The last function used in this exercise is called power 1 z and is simply re alized by calculating the reciprocal value of p use it like the power x function 255 2555 Sout 2 y Sin 2 9 4 10 4 Image Processing 159 50 100 150 200 255 Original Figure 4 10 Creating a Square Root Look up Table Lookup Table vg 200 150 Target 100 LuT Operator L L LU i 50 100 150 200 255 Original Figure 4 11 Creating a Power x Look up Table Figure 4 12 shows the implementation of the power 1 x function in LabVIEW and IMAQ Vision It is easy to see that these functions can be divided into two groups Func tions like logarithmic square root and power 1 x compress regions with high gray level values and expand regions with low gray level values The expo nential square and power x functions operate conversely they expand re gions with high gray level values and compress regions
7. n 4 1 152 IMAGE Processing with LabVIEW and IMAQ Vision National Instruments IA A AG Vision ue Image Binary Machine Vision Script Help Iesus r a 2 FS g ua BS bear bw bmp 8 bit 316x240 gt n ole amp Gray Levels Gray Levels Di 6 32 Toler BU ala e Script 316240171 4 E Histogram Mapping mode Linear Minimum Value 0 00 1 Logarithmic Maximum Value 249 00 Mean Value 96 51 Help Std Deviation 49 60 s i Number of Pixels 75940 _ Cose alal tje Retum j 25 5 75 100 125 150 175 200 225 255 Figure 4 1 Histogram Function in IMAQ Vision Builder with n as the number of pixels with the gray level value k Figure 4 1 shows the histogram function H k for our bear image using IMAQ Vision Builder In addition you can try the following exercise Exercise 4 1 Histogram and Histograph Create a LabVIEW VI that provides the functionality described above directly in IMAQ Vision using the functions IMAQ Histogramand IMAQ Histograph You can find them under Motion and Vision Image Processing Analysis Figure 4 2 shows a possible solution From IMAQ Vision Builder the histogram data can be exported for further processing into MS Excel Figure 4 3 shows the data from Figure 4 1 and 4 2 in an MS Excel diagram If the histogram function is applied to a color image it returns valu
8. 1 1 1 0 1 1 d S4 5 56 7 58 0 il 0 1 1 1 1 al al 0 Connectivity 4 Connectivity 8 Connectivity 8 Square Square Hexagon Figure 4 48 Examples of Structuring Elements The symbols at the top of Figure 4 48 are used by IMAQ Vision Builder to indicate or to set the shape and the connectivity of the structuring element A In the case of a3 x 3 structuring element 190 IMAGE Processing with LabVIEW and IMAQ Vision lin a pixel means that this pixel value is used for the calculation of the new center pixel value according to SQ f 52 84 55 87 4 24 for connectivity 4 and SQ ze f 51 52 83 4 S5 S6 87 Sg 4 25 for connectivity 8 It is also possible to define other bigger structuring elements than the 3 x 3 examples of Figure 4 48 In IMAQ Vision Builder 5 x 5 and 7 x 7 are also possible Note that the procedure is quite similar to the filtering methods we discussed in a previous section In IMAQ Vision Builder you can change the shape of the structuring ele ment by simply clicking on the small black squares in the control see Figure 4 49 Structuring Element Size 5x5 of Iterations E 1 Square Hexagon E Figure 4 49 Configuring the Structuring Element in IMAQ Vision Builder In our following examples and exercises we use a thresholded binary image resulting from our gray scaled bear image by applying the entropy threshold function or you can use manual threshold set upper level to 255
9. 91 for a result of the gray level auto median function E exercise 4 21 Figure 4 91 Gray Morphology Auto Median Function
10. and lower level to 136 The resulting image Figure 4 50 contains a suffi cient number of particles in the background so the following functions have a clearly visible effect Erosion and Dilation These two functions are fundamental for almost all morphology operations Erosion is a function that basically removes sets the value to 0 pixels from the border of particles or objects If particles are very small they may be removed totally 4 Image Processing 191 The algorithm is quite easy if we consider the structuring element centered on the pixel value so If the value of at least one pixel of the structuring element is equal to 0 which means that the structuring element is located at the border of an object so is set to 0 else so is set to 1 Remember that we only consider pixels masked with 1 in the structuring element 4 We can test all relevant morphology functions in Exercise 4 13 Exercise 4 13 Morphology Functions Create a VI that displays the results of the most common binary morphology functions using the IMAQ Vision function IMAQ Morphology Make the structuring element adjustable with a 3 x 3 array control Compare your results to Figure 4 50 which also shows the result of an erosion and Figure 4 51 File Edit Operate Tools Browse Window Help a9 e 13pt Application Font Operation Structuring Element J Erode 3 En om Til C mie me 4 Square ea Al SH Figure 4 50 Morphology Functi
11. computer screen our binary images cannot have only pixel values of 0 and 1 in the 8 bit gray scale set of our monitor we would see no difference between them Therefore all image processing and analysis software including IMAQ Vi sion displays them with gray level values of 0 and 255 respectively 4 Image Processing 189 Binary Morphology As explained above morphology functions change the structure of objects often called particles of a usually binary image Therefore we have to de fine what the term structure or shape means We always talk about images which use pixels as their smallest element with certain properties Objects or particles are coherent groups of pixels with the same properties especially pixel value or pixel value range The shape or structure of an object can be changed if pixels are added to or removed from the border the area where pixel values change of the object To calculate new pixel values structuring elements are used the group of pixels surrounding the pixel to be calculated Figure 4 48 shows some exam ples of the elements defined below m The shape of the structuring element is either rectangular square left and center examples or hexagonal example on the right m The connectivity defines whether four or all eight surrounding pixels are used to calculate the new center pixel value Sy 5 S3 0 1 0
12. detector see Figures 4 28 and 4 30 m If the center coefficient is greater than the sum of the absolute values of all other coefficients the original image is superimposed over the edge information see Figures 4 29 and 4 31 Both gradient and Laplacian kernels correspond to the electrical synonym high pass filter The reason is the same as before sharp edges can be de scribed by high frequencies Frequency Filtering If we follow this idea further we should be able to describe the entire image by a set of frequencies In electrical engineering every periodic waveform can be described by a set of sine and cosine functions according to the Fourier transform and as shown in Figure 4 32 Here the resulting waveform consists of two pure sine waveforms one with f 3Hz and one with f 8Hz which is clearly visible in the fre quency spectrum but not in the waveform window at the top A rectangular waveform on the other hand shows sharp edges and thus contains much higher frequencies as well Coming back to images the Fourier transform is described by 4 Image Processing 175 P E filtered Image File Edit Operate Tools Browse Window Help m iee teene Ee Kernel Family 3 Laplacian 2 Kernel Number y 0 Kernel Size 3 3 Figure 4 28 Filter Example Laplace 0 STE i filtered Image WM Ls ra Kernel Family J Laplacian 2 Kernel Number 3 1 Kernel Size A 3 Predefin
13. for exam ple is the only method out of these five that allows the separation of the image into multiple regions of a certain gray level if the method is applied sequentially All other methods are described in 4 Exercise 4 12 shows you d Sequential clustering is also known as multiclass thresholding 4 186 IMAGE Processing with LabVIEW and IMAQ Vision 5 exercise 4 olx File Edit Operate Tools Browse sg afn 13pt Applic Value Range 0 50 100 150 200 255 IE Binary Image i Figure 4 44 Thresholding with IMAQ Vision i exercise 4 11 vi Diagram E nl x E File Edit Operate Tools Browse Window Help 5 8 e amp u g bal af 13pt Application Font tor Tr T Figure 4 45 Diagram of Exercise 4 11 4 Image Processing 187 how to use them and how to obtain the lower value of the threshold region when these methods are used the upper value is always set to 255 Exercise 4 12 Auto Thresholding Replace the control for adjusting the threshold level in Exercise 4 11 by the function IMAQ AutoBThreshold which returns the respective threshold value depending on the image of course and the selected sta tistical method See Figures 4 46 and 4 47 I exercise 4 1 File Edit Operate Tools Browse Method Jin T inter class variance Threshold Value a iBixi t i cM Figure 4 46 Prede
14. functions such as logarithmic exponential and power We try this in the following exercise Exercise 4 2 Look up Tables In this and the following exercise we compare the fixed IMAQ Vision functions to the impact of manually generated LuTs First of all create the VI shown in Figure 4 5 ie Edit Tools Browse Window Help 2 w gleleri s coss Ee se Figure 4 5 Exercise 4 2 Creating User LuTs 156 IMAGE Processing with LabVIEW and IMAQ Vision Use the function IMAQ UserLookup to generate the second image which is used for the comparison of the result to the built in IMAO function here the function IMAQ MathLookup An XY graph displays the entire LuT by a simple line IE exercise 4 2 vi File Edit Operate Tools Browse Window Help Br Lookup Table Image Types 255 8 bits v 200 LuT Operat f am 150 A Linear 100 P 100 150 200 255 Original exercise 4 2 Figure 4 6 Processing Look up Tables LuTs Figure 4 6 shows the front panel of Exercise 4 2 Case 0 of the VI leaves the gray level values of the original image unchanged which means that the location 0 of the LuT gets the value 0 1 gets 1 and so on until the location 255 which gets 255 The XY graph shows a line from bottom left to top right Another built in LuT is a logarithmic one if the function f g were f g log g then it would be sufficient to add the logarith
15. gray level values therefore we set so to the minimum value of all other coefficients s so min s 4 44 The gray level dilation is shown in Figure 4 85 and is now defined easily so is set to the maximum value of all other coefficients s so max s 4 45 This exercise is a good opportunity to visualize the impact of different con nectivity structures square and hexagon Figure 4 86 shows the same dilation result with square connectivity left and hexagon connectivity right The shape of the objects it is not easy to talk of objects here because we do not have a binary image after eight iterations is clearly determined by the connectivity structure 4 Image Processing 219 I exercise 4 21 E ni x EEE A E r Figure 4 85 Gray Morphology Dilation Gray Morphology 8x Dilation d d Connectivity Square Connectivity Hexagon Figure 4 86 Comparison of Square and Hexagon Connectivity Gray Level Opening and Closing Also in the world of gray level im ages the opening function is defined as a gray level erosion followed by a gray level dilation using the same structuring element opening Z dilation erosion Z 4 46 Figure 4 87 shows the result of a gray level opening function The result of a gray level closing function can be seen in Figure 4 88 The gray level closing function is defined as a gray level dilation followed by a gray level erosion using the same structuring element
16. in IMAQ Vision Builder Thresholding First of all we have to convert the gray scaled images we used in previous ex ercises into binary images The function that performs this operation is called thresholding Figure 4 42 shows this process using IMAQ Vision Builder two gray level values adjusted by the black and the white triangle specify a re gion of values within which the pixel value is set to 1 all other levels are set to 0 Threshold Values Min 138 Max 3 255 Figure 4 42 Thresholding with IMAQ Vision Builder 4 Image Processing 185 Figure 4 43 shows the result Here and in the Vision Builder pixels with value 1 are marked red In reality the image is binary that is containing only pixel values 0 and 1 Figure 4 43 Result of Thresholding Operation Next we try thresholding directly in LabVIEW and IMAQ Vision Exercise 4 11 Thresholded Image Use the function IMAQ Threshold to obtain a binary image In this case use a While loop so that the threshold level can be ad justed easily Note that you have to specify a binary palette with the function IMAQ GetPalette for the thresholded image Compare your results to Figures 4 44 and 4 45 IMAQ Vision also contains some predefined regions for areas with pixel values equal to 1 they are classified with the following names Clustering Entropy Metric Moments m Interclass Variance All of these functions are based on statistical methods Clustering
17. in the resulting image W You can also use special values for the new border pixels for example 0 127 or 255 166 IMAGE Processing with LabVIEW and IMAQ Vision m exercise 4 5 i Diagram File Edit Operate Tools Browse Window Help 5 8 ajn bal 13pt Application Font MESENGA generated LUT Figure 4 18 Diagram of Exercise 4 5 m Finally you can use pixels from the opposite border for the calculation of the new values Kernel Families LabVIEW provides a number of predefined filter kernels it makes no sense to list all of them in this book You can find them in IMAQ Vision Help In a LabVIEW VI window select Help IMAQ Vision and type kernels in the Index tab Nevertheless we discuss a number of important kernels using the prede fined IMAQ groups To do this we have to build a LabVIEW VI that makes it possible to test the predefined IMAQ Vision kernels as well as the manually defined kernels Exercise 4 7 IMAQ Vision Filter Kernels In this exercise VI you will be able to visualize the built in IMAQ Vision filters and this allows you to define your own 3 x 3 kernels Figure 4 21 shows the front panel The Menu Ring Control bottom left 4 Image Processing 167 x i Figure 4 19 Moving the Filter Kernel corner makes it possible to switch between Predefined and Manual Kernel I used Property Nodes here to make the unused controls di
18. objects get bigger You can find more information about the impact of differ ent structuring elements in 4 Figure 4 52 Morphology Dilation Result Opening and Closing Opening and closing are functions that combine erosion and dilation functions The opening function is defined as an erosion followed by a dilation using the same structuring element Mathematically the opening function can be described by opening Z dilation erosion Z 4 28 or using the operator o IoM IOM OM 4 29 Figure 4 53 shows the result of an opening function It is easy to see that objects of the original image are not significantly changed by opening how ever small particles are removed The reason for this behavior is that borders which are removed by the erosion are restored by the dilation function Nat urally if a particle is so small that it is removed totally by the erosion it will not be restored The result of a closing function is shown in Figure 4 54 The closing function is defined as a dilation followed by an erosion using the same structuring element closing Z erosion dilation Z 4 30 194 IMAGE Processing with LabVIEW and IMAQ Vision Figure 4 54 Morphology Closing Result or using the operator e IeM LOGM OM 4 31 Again objects of the original image are not significantly changed Comple mentarily to the opening function small holes in particles can be closed Both opening and closing functio
19. of an image may have been truncated by the choice of the image size In case of further particle analysis they would lead to unreliable results Exercise 4 15 Rejecting Border Particles Replace the function IMAQ Morphology in Exercise 4 13 or IMAQ RemoveParticle in Exercise 4 14 by IMAQ Reject Border The only necessary control is for connectivity 4 or 8 See Figures 4 68 and 4 69 The next function IMAQ ParticleFilter is much more complex and much more powerful Using this function you can filter all particles of an 4 Image Processing 203 File Edit Operate Tools Browse Window Help ag 13pt Application Font Square Connectivity 8 Low Pass A 4 Number of Erosions Je Figure 4 65 Remove Particle Low Pass image according to a large number of criteria Similarly to the previous func tions the particles matching the criteria can be kept or removed respectively Exercise 4 16 Particle Filtering Replace the function IMAQ Morphology in Exercise 4 13 with IMAQ ParticleFilter The control for the selection criteria is an array of clusters containing the criteria names lower and upper level of the criteria values and the selection if the specified interval is to be included or excluded Because of the array data type of this control you can define multiple criteria or multiple regions for the particle filtering operation Figure 4 70 shows an example in which the filtering criterion is the st
20. to make them visible do not forget to cast the image to 8 bits Morphology Functions If you search IMAQ Vision Builder s menus for morphology functions you will find two different types Figure 4 41 m Basic and Advanced Morphology in the Binary menu m Gray Morphology in the Grayscale menu Basically morphology operations change the structure of particles in an image Therefore we have to define the meaning of particle this is easy for a binary image Particles are regions in which the pixel value is 1 The rest of the image pixel value 0 is called background That is why we first learn about binary morphology functions gray level morphology is discussed later in this section Remember that a binary image consists only of two different pixel values 0 and 1 4 Image Processing 183 EX exercise File Edit Operate Tools Browse Window Help ulig ieieti s prionFont w ormal Complex i omplex Figure 4 40 FFT High Pass Attenuation Result 184 IMAGE Processing with LabVIEW and IMAQ Vision S National Instruments C MAQ Vision File Image Color KEEN L Lookup Table Filters gy Particle Filter FFT Filter Invert Binary Image Shape Matching Particle Analysis Circle Detection Operators Conversion Threshold Quantify Centroid Figure 4 41 Morphology Functions
21. 3 Figure 4 64 shows the result of applying the auto median function to our binary bear image Particle Filtering For the next functions which can be found under the Adv Morphology menu in IMAQ Vision Builder we have to slightly modify our Exercise 4 13 because the IMAQ Morphology function does not provide them 202 IMAGE Processing with LabVIEW and IMAQ Vision Ix AutoM Figure 4 64 Morphology Auto Median Result The remove particle function detects all particles that are resistant to a certain number of erosions These particles can be removed similarly to the function of a low pass filter or these particles are kept and all others are removed similarly to the function of a high pass filter Exercise 4 14 Removing Particles Replace the function IMAQ Morphology in Exer cise 4 13 with IMAQ RemoveParticle Provide controls for setting the shape of the structuring element square or hexagonal the connectivity 4 or 8 and the specifi cation of low pass or high pass functionality See Figure 4 65 which also shows the result of a low pass filtering and Figure 4 66 Figure 4 67 shows the result of high pass filtering with the same settings It is evident that the sum of both result images would lead again to the original image The next function IMAQ RejectBorder is quite simple The function removes particles touching the border of the image The reason for this is simple as well Particles that touch the border
22. IMAGE PROCESSING Our images have now found their way from the generation device over transport or storage media to the image processing and analysis software in our case IMAQ Vision As defined in Chapter 1 the output of an image processing operation is still another image this chapter therefore focuses on methods like image manipulation using look up tables filtering morphology and segmentation Here and in Chapter 5 I tried to provide exercises and examples without any addi tional hardware and software When that is not possible I specify exactly the type of hardware equipment and where to get additional software Moreover I keep as close as possible to the IMAQ Vision User Manual 4 which means that I use the same symbols and equations but also give more information and examples Gray Scale Operations The easiest way of course to alter a digital image is to apply changes to its usually 8 bit from 0 to 255 gray level values Before we do this it might be interesting to learn how the gray level values of an image are distributed Histogram and Histograph IMAQ Vision provides two simple tools for this distribution they do almost the same thing m The histogram gives the numeric quantitative information about the distribution of the number of pixels per gray level value m The histograph displays the histogram information in a waveform graph According to 4 the histogram function H k is simply defined as A k
23. acing the function IMAQ Morphology with IMAQ GrayMorphology Add a digital control for Number of iterations and prepare your VI for the use of larger structuring elements for example 5 x 5 and 7 x 7 You will need to specify the number of iterations for the erosion and dilation exam ples larger structuring elements can be used in opening closing proper opening and proper closing examples See Figures 4 83 and 4 84 for results Gray Level Erosion and Dilation Figure 4 83 shows a gray level erosion result after eight iterations we need this large number of iterations here be cause significant results are not so easily visible in gray level morphology As an alternative enlarge the size of your structuring element I exercise 4 21 i loj xl z File Edit Operate Tools Browse Window Help m raeno Operation Structuring Element Erode Number of iterations tjs 4 Square Figure 4 83 Gray Morphology Erosion 218 IMAGE Processing with LabVIEW and IMAQ Vision lB exercise 4 21 vi Diagram File Edit Operate Tools Browse Window Help 5 8 e n e bal 13pt Application Font d zor zm Btructuring Element rs2l lumber of iterations Figure 4 84 Diagram of Exercise 4 21 Of course we have to modify the algorithm of the erosion function In bi nary morphology we set the center pixel value so to 0 if at least one of the other elements s is equal to 0 Here we have
24. are re moved In other words If the value of each surrounding pixel is identical to the value of the structuring element the center pixel so is set to 1 else sq is set to 0 The hit miss function typically produces totally different results depend ing on the structuring element For example Figure 4 57 shows the result of 111 the hit miss function with the structuring element M 111 All pixels 111 in the inner area of objects match M therefore this function is quite similar to an erosion function 000 Figure 4 58 shows the result when the structuring element M 010 000 is used This mask extracts pixels that have no other pixels in their 8 connect ivity neighborhood Itis easy to imagine that the hit miss function can be used for a number of matching operations depending on the shape of the structuring element For 010 example a more complex mask like M 111 will return no pixels at 010 all because none match this mask 4 Image Processing 197 File Edit Operate Tools Browse Window Help o gt c uj 13pt Application Font l EB Operation Structuring Element J Hit miss 7 eo ome Em m m Square ea ot 3 1 Figure 4 57 Hit Miss Result with Structuring Element That Is All 1s More mathematic details can be found in 13 we use the operator for the hit miss function hitmiss Z IOM 4 36 Gradient Functions The gradient functions provide information about pixels el
25. arting x coordinate of the particles All particles starting at an x coordinate greater than 150 are removed See also Figure 4 71 The following list is taken from 5 and briefly describes each criterion that can be selected by the corresponding control The criteria are also used in functions like IMAQ ComplexMeasure in Chapter 5 m Area pixels Surface area of particle in pixels m Area calibrated Surface area of particle in user units 204 IMAGE Processing with LabVIEW and IMAQ Vision c exercise 4 14 i Diagram 0 x Ele Edt Operate Tools Browse Window Help JE e n g bal ot 13pt Application Font Esd Trd Figure 4 67 Remove Particle High Pass Number of holes m Holes area Surface area of holes in user units m Total area Total surface area holes and particles in user units m Scanned area Surface area of the entire image in user units 4 Image Processing 205 Connectivity 8 np ic File Edit Operate Tools Browse Window Help a am bal ot 13pt Application Font Figure 4 69 Diagram of Exercise 4 15 206 IMAGE Processing with LabVIEW and IMAQ Vision File Edit Operate Tools Browse Window Help ag 13pt Application Font lt j Trl Selection Values Keep Particles Parameter sl Left column X Lower Value Upper Value E aj sD 00 150 00 Connectivity 8
26. d by a sum of sine and cosine functions but the result is complex On the other hand the complex format makes it easier to display the results in a two dimensional image 178 IMAGE Processing with LabVIEW and IMAQ Vision iB exercise 4 8 i File Edit Operate Tools Browse Window Help E a e 13pt Application Font orm A Image Pixels Complex Jo 7319216 50 4 96 i 210287 45 56204 95i Normal 249351 55 317488 75 i o2860 50 226340 02 A 13314 58 149034 28 i J 140480 59 84080 231 2463 80 T1815 17i Figure 4 33 FFT Spectrum of an Image IMAQ Vision uses a slightly different function for the calculation of the spectral image the fast Fourier transform FFT The FFT is more efficient than the Fourier transform and can be described by 1 n 1m 1 NETT Su D slayer 4 20 x 0 y 0 where n and m are the numbers of pixels in x and y direction respectively Figure 4 35 shows another important issue the difference between stan dard display of the fast Fourier transform and the optical display The standard display groups high frequencies in the middle of the FFT image whereas low frequencies are located in the four corners left image in Figure 4 35 The op 4 Image Processing 179 exercise 4 8 i Diagram Ele Edt Operate Tools Browse Window Help e a e n 9 bat 13pt Application Font Esd Tr Figure 4 34 FFT Spec
27. e bottom right corner of the image as shown in Figure 4 19 To visualize what happens during the process do Exercise 4 6 Exercise 4 6 Filter Kernel Movement Visualize the movement of a 3 x 3 filter kernel over a simulated image and display the results of Eq 4 12 Figures 4 19 and 4 20 show a possible solution In this exercise I simulated the image with a 10 x 10 array of color boxes Their values have to be divided by 64k to get values of the 8 bit gray scale set The pixel and its eight neighbors are extracted and multiplied by the filter kernel and the resulting values are added to the new pixel value The process described by Eq 4 12 is also called convolution that is why the filter Kernel may be called convolution kernel 4 Image Processing 165 oix File Edit Operate Tools Browse Window Help m Brightness Contrast 255 135 200 150 iol xl E generated LUT ioj x La f id Figure 4 17 Using Special LuTs for Modifying Brightness and Contrast You may have noticed that I did not calculate the border of the new image in Exercise 4 6 the resulting image is only an 8x8 array In fact there are some possibilities for handling the border of an image during spatial filtering m The first possibility is exactly what we did in Exercise 4 6 The resulting image is smaller by the border of 1 pixel m Next possibility The gray level values of the original image remain un changed and are transferred
28. ed fo Figure 4 29 Filter Example Laplace 1 176 IMAGE Processing with LabVIEW and IMAQ Vision E filtered Image Tum SIT Filter Kernel Kernel Family 3 Laplacian 2 Kernel Number Jj 6 Kernel Size jJ 3 File Edit Operate Tools Browse Window Help m 13pt Application Font Kernel Family 3 Laplacian 2 Y Filter Kernel Kernel Number T Kernel Size jl 3 Predefined fo E Figure 4 31 Filter Example Laplace 7 4 Image Processing 177 Waveform 3 07 2 0 m o 1 Amplitude o e 1 D jam o 1 SA 3 0 8 1 1 1 D I t 1 F 1 1 Ie 190250394 49 0590658 m7508509 abo ai T1211 35140 5 9 D 5 GEA S L0 Time Spectrum Figure 4 32 Waveform Spectrum S u v zi s x y e i n mwtwo dy dy 4 18 with s z y as the pixel intensities Try the following exercise Exercise 4 8 Frequency Representation of Images Create a frequency representa tion of our bear image by using the function IMAQ FFT You can switch between two display modes using IMAQ ComplexFlipFrequency both functions are de scribed later Note that the image type of the frequency image has to be set to Com plex see Figures 4 33 and 4 34 The exponential function of Eq 4 18 can also be written as e 1 cos 2ra isin2zo 4 19 and that is why the entire set of pixel intensities can be describe
29. es H k for each color plane for example three histograms for red green and blue in the case of an RGB image Figure 4 4 shows an example using IMAQ Vision Builder Actually the histogram is an image analysis function according to our definition On the other hand we need its results for the following sections so I explain it here 4 Image Processing 153 ip exercise 4 1 vi File Edit Operate Tools Browse Window Help 5 8 on 13pt Application Font id g2 a 1 65 Image Type Histogram Graph 8 bits v Histogram Report histogram 3S le 00 Minimal Value Maximal Value Bag 00 b 00 Starting Value 1 00 3t of Pixels Interval Width bi 30 Mean Value 4 85 Standard Variation 1 1 1 L 100 150 200 A ls 5840 rea pixels Grey Value i exercise 4 1 vi Diagra File Edit Operate Tools Browse Window Help istogram Report Figure 4 2 Histogram and Histograph of an Image Using Look up Tables LuT You know how to adjust brightness and contrast values of your TV set or TV video PC card the intention is to get a better image what obviously means a better distribution of the gray level values This is achieved by a function f g g are the gray level values which assigns a new value to each pixel If we consider Eq 1 1 then our function f g will modify the gray level values according to 154 IMAGE Processing with LabVIEW and IMAQ Vision
30. fined Thresholding Functions Reference 4 also gives the good advice that sometimes it makes sense to invert your image before applying one of those threshold methods to get more useful results An interesting method for the separation of objects from the background is possible if you have a reference image of the background only By calculating the difference image of these two and then applying a threshold function you will get results of a much higher quality You can read more about difference images in the application section of Chapter 5 188 IMAGE Processing with LabVIEW and IMAQ Vision x exercise 4 12 i Diagram File Edit Tools Browse Window Help 2 e M Dlbale gt ron onesie Rex ae F hreshold Value a e Figure 4 47 Diagram of Exercise 4 12 IMAQ Vision also contains a function IMAQ MultiThreshold that allows you to define multiple threshold regions to an image By the way you can also apply threshold regions to special planes of color images for example the hue plane You can also find an interesting application that uses this method in Chapter 5 What about direct thresholding of color images If you use the function IMAQ ColorThreshold you can directly apply threshold values to color images either to the red green and blue plane RGB color model or to the hue saturation and luminance plane HSL color model A final remark Because we usually display our images on a
31. gure 4 72 shows all three steps together the original image the filtered image with only one particle remaining and the result image with all holes filled See Figure 4 73 for the diagram Exercise 4 18 Creating Convex Particles Modify Exercise 4 17 by replacing IMAQ FillHole with IMAQ Convex Set the lower value of the filtering parameters to 1300 and the upper value to 1400 and include this interval This leaves only a single particle near the left image border showing a curved outline IMAQ Convex calculates a convex envelope around the particle and fills all pixels within this outline with 1 Again Figure 4 74 shows all three steps together the orig inal image the filtered image with only one particle remaining and the resulting image with a convex outline See Figure 4 75 for the diagram If you change the parameters of the selection criteria in Exercise 4 18 so that more than one particle remains you will find that our exercise does not work It connects all existing particles The reason for this behavior is that usually the particles in a binary image have to be labeled so that the subsequent func tions can distinguish between them We discuss labeling of particles in a fu ture exercise Separation and Skeleton Functions A simple function for the sepa ration of particles is IMAQ Separation It performs a predefined number of erosions and separates objects that would be separated by these erosions Afterwards the original si
32. image from the image itself thinning Z T hitmiss Z I XOR TOM 4 40 which means that certain pixels that match the mask M are eliminated Sim ilarly to the hit miss function itself the result depends strongly on the struc 200 IMAGE Processing with LabVIEW and IMAQ Vision gt Gradient Figure 4 62 Morphology Thinning Result turing element Figure 4 62 shows the result for the structuring element 111 M 111 110 The thickening function adds the hit miss result of an image to the image itself pixels matching the mask M are added to the original image thickening Z T hitmiss Z T OR ZOM 4 41 10 According to 4 the thinning function does not provide appropriate results if so 0 On the other hand the thickening function does not work if so 1 4 Image Processing 201 Figure 4 63 shows the result of a thickening operation with the structuring 000 element M 000 Both functions can be used to smooth the border of 001 objects and to eliminate single pixels thinning or small holes thickening Figure 4 63 Morphology Thickening Result Auto Median Function Finally the auto median function generates sim pler particles with fewer details by using a sequence of opening and closing functions according to automedian Z opening closing opening 1 4 42 AND closing opening closing Z or using the operator amp Z M Eo M e M o MDn Ze M o M e M 4 4
33. iminated by an erosion or added by a dilation The inner gradient or internal edge function subtracts the result of an erosion from the original im age so the pixels that are removed by the erosion remain in the resulting image see Figure 4 59 for the results inner gradient Z T erosion Z T XOR erosion Z 4 37 Davies 13 uses a different one I prefer because it reminds me of the pixel separation in Figure 4 58 198 IMAGE Processing with LabVIEW and IMAQ Vision File Edit Operate Tools Browse Window Help a amp m 13pt Application Font fff Operation Structuring Element J Htmss 7 babata o Ef o 4 Square fo fo Jo Figure 4 59 Inner Gradient Internal Edge Result 4 Image Processing 199 The outer gradient or external edge function subtracts the original image from a dilation result Figure 4 60 shows that only the pixels that are added by the dilation remain in the resulting image outer gradient Z dilation Z Z T XOR dilation Z 4 38 Figure 4 60 Outer Gradient External Edge Result Finally the gradient function adds the results of the inner and outer gradi ent functions see Figure 4 61 for the result gradient Z inner gradient Z outer gradient Z 4 39 inner gradient Z OR outer gradient Z Thinning and Thickening These two functions use the result of the hit miss function The thinning function subtracts the hit miss result of an
34. l values are re placed by low gray level values and vice versa 0 becomes 255 1 becomes 254 and so forth until 255 which becomes 0 This procedure can be described by Sout Y 255 si my 4 11 Exercise 4 4 Manual Creation of LuTs In this exercise we create the LuT manually by simply subtracting the actual value from 255 as in Eq 4 11 The resulting images and the LuT are shown in Figure 4 15 the diagram is shown in Figure 4 16 Now you know why you should plot the LuTs in an XY graph In most cases you can predict the results by simply looking at the plotted LuT For example if the LuT graph rises from bottom left to top right then the re sulting image will be not inverted if it looks like a logarithmic function the overall brightness of the resulting image will be increased because the log function compresses regions of high gray level values 4 Image Processing 161 gt exercise 4 3 vi File Edit Operate Tools Browse Window Help gt a9 Sjn 13pt Application Font w tar a Histogram Graph Equalized Image Histogram 1400 1200 1000 9 800 600 L Li 00 150 200 250 300 Grey Value Ii x n s 7 of Pixels 40 0 7 i NI 07 1 0 50 1 Figure 4 13 Image and Histogram Resulting from Equalizing Special LuTs BCG Values Another method is shown in Exercise 4 5 Instead of creating the LuT by using mathematical functions we can use the functio
35. lement can be either 0 or 1 and produces the result shown in Figure 4 79 Figure 4 81 shows the result of the M skeleton function Typically the M skeleton leads to skeleton lines with more branches thus filling the area of 4 Image Processing 215 Mode Jj Skeleton L Ix Skeleton L Figure 4 79 L Skeleton Function exercise 4 20 vi Diagram loj x Eile Edit Operate Tools Browse Window Help JE o u 9 bal of 13pt Application Font ESTIS IMAQ p IMAQ Figure 4 80 Diagram of Exercise 4 20 216 IMAGE Processing with LabVIEW and IMAQ Vision the original particles with a higher amount The M skeleton function uses ddl the structuring element M 011 5 ddl Skeleton M i Figure 4 81 M Skeleton Function The skiz function Figure 4 82 is slightly different Imagine an L skeleton function applied not to the objects but to the background You can try this with our Exercise 4 20 Modify it by adding an inverting function and com pare the result of the Skiz function to the result of the L skeleton function of the original image Figure 4 82 Skiz Function 4 Image Processing 217 Gray Level Morphology We return to the processing of gray scaled images in the following exercises Some morphology functions work not only with binary images but also with images scaled according to the 8 bit gray level set Exercise 4 21 Gray Morphology Functions Modify Exercise 4 13 by repl
36. m base 10 function of LabVIEW to case 1 and watch the results 4 Image Processing 157 Oops that did not work Naturally the logarithm base 10 of 255 is about 2 4 so we have to scale the entire range of resulting values to the 8 bit gray scale set The resulting function is 255 Sout 2 y log sin y log 255 log sin x y 105 96 4 5 and is shown in Figure 4 7 Lookup Table 255 200 150 Target 100 LuT Operator 1 1 1 1 50 100 150 200 255 Original Figure 4 7 Creating a Logarithmic Look up Table The next function is exponential If we generate it the way we did above we see a far too steep function because the values rise too fast A correction factor c according to 255 exp 255 c Ee Sout x y exp Sin z y c leads to more reasonable results c 48 is the value used in the built in IMAQ function see the realization of this equation in Figure 4 8 The square function is easy If we multiply the value location by itself and scale it like we did above we get 255 255 Figure 4 9 shows the corresponding results 1 sin 09 zo 4 7 Sout y Sin 2 y Square root is quite similar Figure 4 10 shows the results and here is the function 158 IMAGE Processing with LabVIEW and IMAQ Vision Lookup Table Pos 50 100 150 200 255 Original Figure 4 8 Creating an Exponential Look up Table
37. n IMAQ BCGLookup which changes the following parameters m Brightness the median value of the gray level values If the LuT is drawn as a line as in the previous exercises changing the brightness value shifts the line to the top lighter or to the bottom darker W Contrast the difference from one gray level value to another Varying the contrast value changes the slope of the line in the XY graph m Gamma the gamma coefficient is equal to the power factor p we used in the previous exercises If the gamma value is equal to 1 the graph always remains a straight line 162 IMAGE Processing with LabVIEW and IMAQ Vision exercise 4 3 vi Diagram File Edit Operate Tools Browse Window Help aln Y ba 13pt Application Font J ualized Image Histogram EA ppa Figure 4 14 Diagram of Exercise 4 3 Exercise 4 5 compares the IMAQ function with a self constructed one Exercise 4 5 BCG Look up Table The IMAQ function IMAQ BCGLookup modifies the image by changing the values of brightness contrast and gamma Create a VI that does the same with a manually generated LuT Figure 4 17 shows a possible solution Figure 4 18 shows the diagram I did only the brightness and the contrast adjustment the realization of the gamma coefficient is left for you Spatial Image Filtering As the word filtering suggests most of the methods described in this section are used to improve the quality of the image In gene
38. ns use the duality of erosion and dilation operations The proof for this duality can be found in 13 Proper Opening and Proper Closing IMAQ Vision provides two addi tional functions called proper opening and proper closing Proper opening is defined as a combination of two opening functions and one closing function combined with the original image 4 Image Processing 195 proper opening Z Z AND opening closing opening Z 4 32 or Torop M IN IoM eM oM 4 33 As Figure 4 55 shows the proper opening function leads to a smoothing of the borders of particles Similarly to the opening function small particles can be removed Figure 4 55 Morphology Proper Opening Result Proper closing is the combination of two closing functions combined with one opening function and the original image proper closing Z T OR closing opening closing Z 4 34 or Terp M ZU Ee M o M e M 4 35 Proper closing smooths the contour of holes if they are big enough so that they will not be closed Figure 4 56 shows that there is only a little difference between the original image and the proper closing result 196 IMAGE Processing with LabVIEW and IMAQ Vision Figure 4 56 Morphology Proper Closing Result Hit Miss Function This function is the first simple approach to pattern matching techniques In an image each pixel that has exactly the neighbor hood defined in the structuring element mask is kept all others
39. ns would have split the object See Figure 4 77 for the diagram File Edit Operate Tools Browse Window rig 13pt Application Font Structuring Element fae me a TT Bge E Ji 1o 4 A Square Number of Erosions J 5 Figure 4 76 Separation of Particles The next exercise is taken directly from IMAQ s own examples IMAQ MagicWand Just open the help window with the VI IMAQ MagicWand se lected you can find it in the Processing submenu and click on MagicWand example the example shown in Figure 4 78 is displayed Here you can click on a region of a gray scaled image which most likely would be a particle after a thresholding operation The result is displayed 4 Image Processing 213 exercise EET Diagram File Edit Operate Tools Browse Window Help 5 a9 e n9 ba oF 13pt Application Font tor zd Figure 4 77 Diagram of Exercise 4 19 in a binary image and shows the selected object Additionally the object is highlighted in the original gray level image by a yellow border Figure 4 78 also shows the use of the IMAQ MagicWand function in the respective VI diagram The last three functions in this section are similar to the analysis VIs we discuss in Chapter 5 they already supply some information about the particle structure of the image Prepare the following exercise first Exercise 4 20 Skeleton Images Again take one of the previous simple exercises for e
40. of the x axis squared for each pixel of the particle SumYY Sum of the y axis squared for each pixel of the particle SumXY Sum of the x axis and y axis for each pixel of the particle Corrected projection x Projection corrected in x 208 IMAGE Processing with LabVIEW and IMAQ Vision Corrected projection y Projection corrected in y Moment of inertia Izz Inertia matrix coefficient in xz Moment of inertia I Inertia matrix coefficient in yy Moment of inertia Izy Inertia matrix coefficient in xy Mean chord X Mean length of horizontal segments Mean chord Y Mean length of vertical segments Max intercept Length of longest segment Mean intercept perpendicular Mean length of the chords in an object per pendicular to its max intercept Particle orientation Direction of the longest segment Equivalent ellipse minor axis Total length of the axis of the ellipse having the same area as the particle and a major axis equal to half the max intercept Ellipse major axis Total length of major axis having the same area and perimeter as the particle in user units Ellipse minor axis Total length of minor axis having the same area and perimeter as the particle in user units m Ratio of equivalent ellipse axis Fraction of major axis to minor axis Rectangle big side Length of the large side of a rectangle having the same area and perimeter as the particle in user units Rectangle small side Length of the small side of a
41. ons Erosion Note that some small particles in the background have disappeared also note that the big particles are smaller than in the original image Try different structuring elements by changing some of the array elements and watch the results 192 IMAGE Processing with LabVIEW and IMAQ Vision I exercise 4 13 vi Diagram File Edit Operate Tools Browse Window Help 5 8 e amp n e bal 13pt Application Font d zor zm Figure 4 51 Diagram of Exercise 4 13 A special notation for morphology operations can be found in 13 which shows the structure of concatenated functions very clearly If 7 is an image and M is the structuring element mask the erosion operator 6 is defined as erosion Z 1 O M fweMI a 4 26 where Z indicates a basic shift operation in direction of the element a of M Z 4 would indicate the reverse shift operation 13 A dilation adds pixels sets their values to 1 to the border of particles or objects According to 13 the dilation operator is defined as dilation Z TG M UaceMm Ta 4 27 Again the structuring element is centered on the pixel value so If the value of at least one pixel of the structuring element is equal to 1 s is set to 1 else so is set to 0 13 Figure 4 52 shows the result of a simple dilation Note that some holes in objects the bear s eyes for example are closed or nearly closed very small 4 Image Processing 193
42. ral these methods calcu late new pixel values by using the original pixel value and those of its neigh bors For example we can use the equation 1 m 1m 1 Sout 2 9 2 S sin w k uytk v f u v 7 4 12 u 0 v 0 which looks very complicated Let s start from the left Eq 4 12 calculates new pixel values Sout by using an m x m array Usually m is 3 5 or 7 in most 4 Image Processing 163 B exercise 4 4 vi File Edit Operate Tools Browse Window Hel TE Om pwenn ES E I Figure 4 15 Inverting the Bear Image of our exercises we use m 3 which means that the original pixel value sin and the values of the eight surrounding pixels are used to calculate the new value k is defined as k m 1 2 The values of these nine pixels are modified with a filter kernel f 0 0 f 0 1 f 0 2 F f u v f 1 0 f 1 1 f 1 2 i 4 13 f 2 0 f 2 1 f 2 2 As you can see in Eq 4 12 the indices u and v depend upon z and y with k m 1 2 Using indices x and y we can write 164 IMAGE Processing with LabVIEW and IMAQ Vision exercise 4 4 i Diagram File Edit Operate Tools Browse Window Help 5 a9 Sjn bal 13pt Application Font d zor 5l Open Image iem Figure 4 16 Diagram of Exercise 4 4 F f r Ly f oy fle 1 y 4 14 which specifies the pixel itself and its eight surrounding neighbors The filter kernel moves from the top left to th
43. rectangle having the same area and perimeter as the particle in user units Ratio of equivalent rectangle sides Ratio of rectangle big side to rectangle small side Elongation factor Max intercept mean perpendicular intercept m Compactness factor Particle area height x width m Heywood circularity factor Particle perimeter perimeter of circle having the same area as the particle Type factor A complex factor relating the surface area to the moment of inertia 4 Image Processing 209 m Hydraulic radius Particle area particle perimeter m Waddel disk diameter Diameter of the disk having the same area as the particle in user units m Diagonal Diagonal of an equivalent rectangle in user units Fill Holes and Convex These two functions can be used for correcting the shape of objects which should be circular but which show some enclosures or holes in the original binary image These holes may result from a threshold operation with a critical setting of the threshold value for example Exercise 4 17 Filling Holes Modify Exercise 4 16 by adding IMAQ FillHole after IMAQ ParticleFilter We use particle filtering here so only one particle with holes remains If you use the criterion Area pixels set the lower value to 0 and the upper value to 1500 and exclude this interval then only the bear s head with the eyes as holes remains You can use a case structure to decide whether the holes should be filled or not Fi
44. sappear Next let s look at the diagram Figure 4 22 The processing function we use here is IMAQ Convolute the predefined kernels are generated with IMAQ GetKernel So far so good but if we use manual kernels we have to calculate a value called Divider which is nothing more than 1 m in Eq 4 12 Obviously 1 m is not the correct expression for the divider if we want to keep the overall pixel brightness of the image Therefore we must calculate the sum of all kernel elements for the divider value with one exception of course 0 In this case we set the divider to 1 000 This happens quite often for example consider a kernel F 1 1 0 000 Note that if you wire a value through a case structure in LabVIEW you have to click once within the frame 168 IMAGE Processing with LabVIEW and IMAQ Vision Ex exercise 4 6 vi Diagram File Edit Operate Tools Browse Window Help La exercise 4 7 vi File Edit Operate Tools Browse Wind BESOTE Figure 4 21 Visualizing Effects of Various Filter Kernels 4 Image Processing 169 exercise 4 7 vi Diagram File Edit Operate Tools Browse Window Help 5 8 ang bal af 13pt Application Font j 22 TaY Figure 4 22 Diagram of Exercise 4 7 The four filter families which you can specify in Exercise 4 7 as well as in the Vision Builder are m Smoothing m Gaussian m Gradient m Laplacian Image Smoothing All smoothing filters build a weigh
45. syn onym low pass filter because sharp edges which are removed by these filters can be described by high frequencies Edge Detection and Enhancement An important area of study is the detection of edges in an image An edge is an area of an image in which a significant change of pixel brightness occurs Filter Families Gradient A gradient filter extracts a significant bright ness change in a specific direction and is thus able to extract edges rectangu lar to this direction Figure 4 25 shows the effect of a vertical gradient filter which extracts dark bright changes from left to right 172 IMAGE Processing with LabVIEW and IMAQ Vision File Edit Operate Tools Browse Window Help m iae SENE E Kernel Family cJ Gradient T Kernel Number Jo 1 0 oo 10 Kernel Size as 1 0 Joo J 10 1 0 oof Lo Predefined V fo Figure 4 25 Filter Example Gradient 0 Note that the center coefficient of this kernel is 0 if we make it equal to 1 as in Figure 4 26 the edge information is added to the original value The orig inal image remains and the edges in the specified direction are highlighted Figure 4 27 shows the similar effect in a horizontal direction dark bright changes from bottom to top Gradient kernels like those in Figure 4 25 and Figure 4 27 are also known as Prewitt filters or Prewitt kernels Another group of gradient kernels for 1 01 example F
46. ted average of the surrounding pixels and some of them also use the center pixel itself Filter Families Smoothing A typical smoothing kernel is shown in Fig ure 4 23 Here the new value is calculated as the average of all nine pixels using the same weight 170 IMAGE Processing with LabVIEW and IMAQ Vision I i 4 File Edit Operate Tools Browse Window Help nu rs Appication Fort fozi Predefined x fo Figure 4 23 Filter Example Smoothing 5 z41 y 1 Sout Y 5 5 Sinlu v 4 15 u g 1 v y 1 010 020 Other typical smoothing kernels are F 101 0 F 212 2 010 020 222 or F 212 6 Note that the coefficient for the center pixel is either 0 222 or I all other coefficients are positive Filter Families Gaussian The center pixel coefficient of a Gaussian ker nel is always greater than 1 and thus greater than the other coefficients be cause it simulates the shape of a Gaussian curve Figure 4 24 shows an exam ple 4 Image Processing 171 ojx File Edit Operate Tools Browse Window Help om Kernel Family oj Gaussian 4 Kernel Number Jj 4 Kernel Size Jj 3 Predefined x fo x D a Filter Kernel Figure 4 24 Filter Example Gaussian 4 010 More examples for Gaussian kernels are F 121 0 010 010 111 F 141 orF 141 G5 010 111 Both smoothing and Gaussian kernels correspond to the electrical
47. trum of an Image tical display behaves conversely Low frequencies are grouped in the middle and high frequencies are located in the corners I Complex FFT Standard Disp 1olxli gt Complex FFT Optical Display Low Frequencies Figure 4 35 FFT Spectrum Standard and Optical Display Note a mistake in IMAQ Vision s help file IMAQ FFT generates output in optical display not in standard 180 IMAGE Processing with LabVIEW and IMAQ Vision FFT Filtering Truncate If we have the entire frequency information of an image we can easily remove or attenuate certain frequency ranges The simplest way to do this is to use the filtering function IMAQ ComplexTruncate You can modify Exercise 4 8 to do this Exercise 4 9 Truncation Filtering Add the function IMAQ ComplexTruncate to Exercise 4 8 and also add the necessary controls see Figures 4 36 and 4 37 The con trol called Truncation Frequencies specifies the frequency percentage below which high pass or above which low pass the frequency amplitudes are set to 0 In addition use IMAQ InverseFFT to recalculate the image using only the remain ing frequencies Figure 4 36 shows the result of a low pass truncation filter Figure 4 38 the result of a high pass truncation filter File Edit Operate Tools Browse Window Help ae c uj 13pt Application Font Normal High Pass Truncation Frequency 95 Optical Low Pass Complex FFT
48. with low gray level values The power value p is often called gamma coefficient it indicates the degree of impact of the power function We return to it in Exercise 4 5 Special LuTs Equalize and Inverse IMAQ Vision also contains a func tion called IMAQ Equalize which distributes the gray level values evenly over the entire gray scale set usually 0 to 255 for 8 bits If an image does not 160 IMAGE Processing with LabVIEW and IMAQ Vision Lookup Table 255z 200 150 100 50 Target LuT Operator 100 150 200 255 Original Figure 4 12 Creating a Power 1 x Look up Table use all available gray levels most images do not the contrast the difference from one gray level to another of the image can be increased Exercise 4 3 Equalizing Images Create a VI that equalizes our bear image In this case it is not so easy to create a user defined LuT so we concentrate on the his tograms Both of them can be seen in Figure 4 13 Figure 4 14 shows the diagram The histogram of the equalized image in Figure 4 13 is quite interesting It is obviously not a solid line like the histogram of the original image This is because the equalize function distributes an equal amount of pixels over a constant gray level interval If not all gray level values are used in the original image the histogram of the resulting image contains values without pixels The next function is very simple inverse High gray leve
49. xample Exercise 4 14 and replace its IMAQ Vision function by IMAQ Skeleton You will need only a single control for the skeleton mode with that control you select the Skeleton L Skeleton M or Skiz function See Figure 4 79 showing a Skeleton L function and Figure 4 80 for the results All skeleton functions work according to the same principle they apply combinations of morphology operations most of them are thinning func tions until the width of each particle is equal to 1 called the skeleton line Other declarations for a skeleton function are these m The skeleton line shall be in approximately the center area of the orig inal particle 214 IMAGE Processing with LabVIEW and IMAQ Vision File Edit perds Tok Browse Window Help a e Demonstration Image Path Skripten IMAQ_Bookipic ae fasts 1 First load an image Load file file and display it 2 Click on the object you want to segment Connectivity Tolerance Tolerance GL 2 n Connectivity 8 Figure 4 78 IMAQ MagicWand Separating Objects from the Background National Instruments Example m The skeleton line shall represent the structure and the shape of the orig inal particle This means that the skeleton function of a coherent particle can only lead to a coherent skeleton line 0d1 The L skeleton function is based on the structuring element M 011 0d1 see also 5 the d in this mask means don t care the e
50. ze of the particles is restored 210 IMAGE Processing with LabVIEW and IMAQ Vision Ele Edit Operate Tools Br oo Fill Holes Connectivity 8 14 7 Fill Holes Fill Holes Figure 4 72 Filling Holes in Particles exercise 4 17 vi Diagram File Edit Operate Tools Browse Window Help d ejn A bol af 13pt Application Font od 3is 0 00 1500 TH Figure 4 73 Diagram of Exercise 4 17 4 Image Processing 211 EE 1O x File Edit Operate Tools Bro Convex Connectivity 8 Figure 4 74 IMAQ Convex Function exercise 4 18 i Diagram 1 0 x File Edit Operate Tools Browse Window Help d c uj A ballat 13pt Application Font IES Tr 1300 1400 Eri Figure 4 75 Diagram of Exercise 4 18 212 IMAGE Processing with LabVIEW and IMAQ Vision Exercise 4 19 Separating Particles Take one of the previous simple exercises for example Exercise 4 14 and replace its IMAQ Vision function with IMAQ Separati on You will need controls for the structuring element the shape of the structuring element and the number of erosions The separation result is not easily visible in our example image Have a look at the particle with the curved outline we used in the convex exercise In Figure 4 76 this particle shows a small separation line in the resulting image This is the location where the erosio
Download Pdf Manuals
Related Search
Related Contents
VAE, mode d`emploi, Les annonces de l`optique Com`X 200 - Schneider Electric aceites has no - Z Gibraltar Mailboxes HCPL10V01 Installation Guide Actuador rotativo de diafragma Fisher 1052, tamaño 20, con Origin Storage 500GB Job Referral Service - Government of Manitoba HP 3M LX600 Specialty Latex Ink Copyright © All rights reserved.
Failed to retrieve file