Abstract:
An image measuring apparatus includes: an imaging device of a rolling shutter type configured to image a work; a position control system configured to output a focusing position as information representing a position in a direction of a focusing axis by controlling an in-focus position of the imaging device; and a computing device configured to calculate, from image information acquired from the imaging device, contrast information corresponding to the image information, wherein the computing device divides an acquired image into a plurality of regions and corrects the contrast information corresponding to the image information based on a position of and the contrast information corresponding to each of the regions.

Description:
BACKGROUND 
       [0001]    1. Field of the Invention 
         [0002]    The present invention relates to an image measuring apparatus for measuring a measuring object by imaging the measuring object. 
         [0003]    2. Description of the Related Art 
         [0004]    In an image measuring apparatus having an autofocusing function, images of a measuring object are sequentially acquired while an imaging device such as a camera or an optical system of the imaging device is moved in the direction of the optical axis thereof. Then, an in-focus position in the direction of the optical axis of the imaging device is calculated from the contrast of each of the images (see JP-A-2009-168607). 
         [0005]    Hitherto, generally, an imaging device of the global shutter type has been mounted on such an image measuring apparatus. The imaging device of the global shutter type is suited to the above contrast type autofocusing, because exposure is performed simultaneously at all light receiving elements thereof. 
         [0006]    On the other hand, an imaging device of the rolling shutter type has been known as that of the type differing from that of the global shutter type. The imaging device of the rolling shutter type is low in price, as compared with that of the global shutter type. However, when utilized for the above contrast type autofocusing, the imaging device of the rolling shutter type has the following problems. 
         [0007]    That is, the imaging device of the rolling shutter type performs imaging sequentially on each column or pixel of light receiving elements configured by being arranged like an array. Accordingly, when imaging is performed while the imaging device of the rolling shutter type is moved in the direction of the optical axis, the position of the imaging device varies with that of the pixel at which an image is acquired. 
         [0008]    When the position of the imaging device at the center of the light receiving timings of the light receiving elements is employed as a reference position, information on the position of the imaging device is acquired as that representing an imaging position, simultaneously with the reception of light by a centrally positioned one of the light receiving elements arranged like an array. Thus, a part, on which imaging is performed just after the start of the imaging, is imaged before the imaging at the reference position. Similarly, a part, on which imaging is performed just before the end of the imaging, is imaged after the reference position. Accordingly, if a part at which the contrast changes most in an imaging range is located apart from the center position of the imaging range, an error is caused between the in-focus position determined based on the contrast calculated from the acquired image and the acquired imaging position. 
       SUMMARY 
       [0009]    The invention is accomplished in view of such a respect. An object of the invention is to inexpensively provide an image measuring apparatus capable of performing high-precision autofocusing. 
         [0010]    According to a first aspect of the invention, there is provided an image measuring apparatus includes an imaging device of the rolling shutter type configured to image a work, a position control system configured to output a focusing position as information representing a position in the direction of a focusing axis by controlling an in-focus position of the imaging device, and a computing device configured to calculate, from image information acquired from the imaging device, contrast information corresponding to the image information. The computing device divides an acquired image into multiple regions and corrects the contrast information corresponding to the image information based on a position of and the contrast information corresponding to each of the regions. 
         [0011]    According to a second aspect of the invention, the computing device corrects contrast information of each region from contrast information and imaging timing corresponding to each of prior image information and subsequent image information respectively representing a prior image and a subsequent image thereof, which are consecutively imaged. 
         [0012]    According to a third aspect of the invention, the computing device calculates contrast information concerning each of regions respectively corresponding to the prior image information and the subsequent image information, multiplies the contrast information by a weight corresponding to imaging timing thereof, and sums results of the multiplication. 
         [0013]    According to the invention, an image measuring apparatus capable of performing high-precision autofocusing can inexpensively be provided. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0014]    The present invention will become more fully understood from the detailed description given hereinbelow and the accompanying drawing which is given by way of illustration only, and thus is not limitative of the present invention and wherein: 
           [0015]      FIG. 1  is an overall diagram illustrating an image measuring apparatus according to a first embodiment of the invention; 
           [0016]      FIG. 2  is a block diagram illustrating the configuration of the image measuring apparatus; 
           [0017]      FIG. 3  is a block diagram illustrating the configuration of a part of the image measuring apparatus; 
           [0018]      FIG. 4  is a graph illustrating an autofocusing method performed in the image measuring apparatus; 
           [0019]      FIG. 5  is a timing chart illustrating imaging timing in an imaging device of the global shutter type; 
           [0020]      FIG. 6  is a timing chart illustrating an example of imaging timing in an imaging device of the rolling shutter type; 
           [0021]      FIGS. 7A to 7C  are diagrams each illustrating an example of an image imaged by the imaging apparatus during an autofocusing operation; and 
           [0022]      FIG. 8  is a diagram for describing a contrast correction method performed in the imaging apparatus according to the first embodiment of the invention. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     First Embodiment 
       [0023]    Next, the configuration of an image measuring apparatus according to the first embodiment of the invention is described hereinafter in detail with reference to the drawings. 
         [0024]      FIG. 1  is an overall diagram illustrating an image measuring apparatus according to the present embodiment. The image measuring apparatus includes an image measuring instrument  1  on which a camera  141  is mounted as an imaging device for imaging a work  3 , and a computer (hereinafter referred to as a “PC”)  2  electrically connected to the image measuring instrument  1 . 
         [0025]    The image measuring instrument  1  is configured as follows. That is, a specimen table  12  is placed on a specimen moving means  11  such that the top surface of the specimen table  12  coincides with a horizontal plane as a base surface. An X-axis guide  13   c  is supported at the top end of each of arm support members  13   a  and  13   b  erected on both side ends of the specimen moving means  11 . The specimen table  12  is driven in Y-axis direction by the specimen moving means  11 . On the X-axis guide  13   c,  an imaging unit  19  is moveably supported in X-axis direction. A complementary metal-oxide semiconductor (CMOS) camera  141  of the rolling shutter type is attached to the bottom of the imaging unit  14 . 
         [0026]    Incidentally, the present embodiment has a configuration in which the work  3  placed on the specimen table  12  is imaged. Apparently, an embodiment of the invention can have another configuration, e.g., a configuration in which a work placed on a floor is sideways imaged. 
         [0027]      FIG. 2  is a block diagram illustrating the configuration of the image measuring apparatus according to the present embodiment. According to the present embodiment, the image measuring apparatus includes, e.g., a controller  15  provided in the image measuring instrument  1 . The controller  15  includes a position control system  151  and an illumination control device  152 . The imaging unit  14  includes an illumination device  142  for irradiating light onto the work  3 . The PC  2  controls a focal position of the camera  141  via the position control system  151 . In addition, the PC  2  sends a signal designating a frame rate to the camera  141 , and a signal designating an amount of light of the illumination device  142  to the illumination device  142 , respectively. The camera  141  images the work  3  irradiated with light from the illumination device  142 , at a designated frame rate. Then, the camera  141  sends image information to the PC  2 . At that time, position information representing the position of the camera  141  is sent from the position control system  151 . Incidentally, various types of illumination equipment can be used as the illumination device  142 . For example, a pulse width modulation (PM) controlled light emitting diode (LED) can also be used as the illumination device  142 . 
         [0028]    Next, the configuration of the imaging unit  14  in the image measuring apparatus according to the present embodiment is described hereinafter.  FIG. 3  is a block diagram illustrating the configuration of a part of the image measuring apparatus according to the present embodiment. In the present embodiment, the imaging unit  14  includes the camera  141 , a linear encoder  143  for detecting and outputting the Z-coordinate of the camera  141 , a camera drive mechanism  144  for driving the camera  141  in the direction of Z-axis, and a Z-axis motor  145  for driving the camera drive mechanism  144 . The Z-axis motor  145  is controlled by the position control system  151  via a power unit  16  provided in the image measuring instrument  1 . The linear encoder  143  is attached to the imaging unit  14  such that a scale or a detection head moves in the direction of the Z-axis interlockingly with the camera  141 . The position control system  151  includes a latch counter and a Z-value latch buffer. The position control system  151  acquires, from the linear encoder  143 , Z-coordinate information representing the Z-coordinate of the camera  141  in the response to a trigger signal, and retains the acquired Z-coordinate information in the Z-value latch buffer. The camera  141  is connected to the PC  2  via a universal serial bus (USB) cable, and to the position control system  151  via a dedicated digital input/output (DIO). 
         [0029]    The position control system  151  outputs a Z-axis drive instruction to the power unit  16 . The power unit  16  supplies electric drive power to the Z-axis motor  145 . The Z-axis motor  145  drives the camera  141  by the camera drive mechanism  144 . The camera  141  performs imaging at an optional frame rate, and sends image information to the PC  2  via the OSB cable. At that time, the image measuring apparatus can be adapted such that a vertical synchronization signal, is output from the camera  141  to the position control system  151  as a trigger signal. In this case, the position control system  151  receives a vertical synchronization signal, and acquires a Z-coordinate of the camera  141  from the encoder  143  in response to the received signal. The acquired Z-value is retained in the Z-value latch buffer. In addition, the latch counter is updated. The retained Z-value is transmitted to the PC  2  in response to a read instruction. Although the camera  141  is driven in the direction of the Z-axis in the present embodiment, a similar operation can be performed by adjusting an optical system, such as a lens, provided in the camera  141 . In addition, although a USB interface is used as a digital serial communication means in the present embodiment, apparently, other means such as a gigabit-Ethernet (Gig-E) interface, and a FireWire (registered trademark) interface can be used as the digital serial communication means. Alternatively, analog communication means (providing NTSC output, or composite output) can be used, instead of the digital serial communication means. In the case of using the analog communication means, the PC  2  acquires an image via a frame grabber. 
         [0030]    Next, an autofocusing method performed in the image measuring apparatus according to the present embodiment is described hereinafter.  FIG. 4  is a graph illustrating an autofocusing method performed in the image measuring apparatus according to the present embodiment. The axis of abscissas represents the Z-coordinate of the camera  141 , and the axis of ordinates represents contrast. 
         [0031]    During autofocusing in the image measuring apparatus according to the present embodiment, imaging is performed at plural Z-coordinates. Then, contrast is calculated from an image obtained at each coordinate position. In addition, a contrast curve represented by a solid line shown in  FIG. 4  is obtained, based on the plural calculated contrast-values. Then, a peak position of the contrast curve is determined as an in-focus position. In the case of the example illustrated in  FIG. 4 , imaging is performed at the Z-coordinates (Z 1  to Z 7 ) of seven positions. In addition, the contrast-values (P 1  to P 7 ) respectively corresponding to the Z-coordinates are calculated. 
         [0032]    Hitherto, when an image is acquired during autofocusing of such a contrast type, a charge-coupled device (CCD) camera of the global shutter type has been used.  FIG. 5  is a timing chart illustrating imaging timing in an imaging device of the global shutter type. 
         [0033]    An upper part of  FIG. 5  illustrates exposure timing of an imaging element of the COD camera, while a lower part of  FIG. 5  illustrates timing of outputting each of image information and a vertical synchronization signal. As illustrated in  FIG. 5 , all imaging elements are simultaneously exposed in the CCD camera of the global shutter type. Then, images are sequentially transferred. 
         [0034]    On the other hand, the pixel columns of a CMOS camera of the rolling shutter type differ from one another in imaging-timing.  FIG. 6  is a timing chart illustrating an example of the imaging timing in the CMOS camera of the rolling shutter type. 
         [0035]    Similarly to  FIG. 5 , an upper part of  FIG. 6  illustrates exposure timing of the CMOS camera, while a lower part of  FIG. 6  illustrates timing of each of outputting image information and a vertical synchronization signal. For convenience of description, it is now assumed that the number of pixels of the CMOS camera is x×y, that the coordinate of a top-left pixel is (1, 1), and that the coordinate of a bottom-right pixel is (x, y) 
         [0036]    When imaging is started in the CMOS camera of the rolling shutter type, light receiving elements arranged like pixels (1,1), (2,1), (3,1), . . . on a first line are sequentially exposed. Then, light receiving elements arranged on each of second and later lines are similarly exposed sequentially from the second line. Image information corresponding to each pixel, which is obtained by the imaging element, is output from each pixel, simultaneously with the end of receiving light at each pixel. 
         [0037]    During an autofocusing operation, the camera  141  is moved by simultaneously imaging the work  3 . The position in the direction of the Z-axis of the camera  141  at the start of imaging of 1 frame at that time is assumed to be Z 1 . An intermediate position in the direction of the Z-axis of the camera  141  is assumed to be Z 2 , The position in the direction of the Z-axis of the camera  141  at the end of imaging of 1 frame is assumed to be Z 3 . In this case, the position of the camera  141  at the time of imaging the pixel (1, 1) is Z 1 . The position of the camera  141  at the time of imaging the pixel at the central position of an imaging range is Z 2 . The position of the camera  141  at the time of imaging the pixel (x, y) is Z 3 . 
         [0038]    If the position (hereinafter referred to as a “reference position”) in the direction of the Z-axis of the camera  141 , which is latched by the position control system  151 , is assumed to be Z 2 , Z 2  is retained in the Z-value latch buffer. Then, Z 2  is transferred to the PC  2 . Thus, the PC  2  recognizes that all image data of the pixels from (0, 0) to (x, y) are imaged while the position of the camera  141  is Z 2 . Accordingly, an error is caused between the position of the camera  141  at the time of actually imaging each of the pixels and that of the camera  141  at that time, which is recognized by the PC  2 . In this case, the error at the time of imaging the pixel (1, 1) is Z 2 −Z 1 . The error at the time of imaging the pixel (x, y) is Z 3 −Z 2 . Both of the errors are maximum values. 
         [0039]      FIGS. 7A to 7C  each illustrate an example of an image imaged by the camera  141  during an autofocusing operation.  FIG. 7A  illustrates a whole image of the imaging range.  FIGS. 7B and 7C  each is an enlarged view of an image inside a tool T illustrated in  FIG. 7A , which determines an image range used for autofocusing It is now assumed that there is a region B, at which contrast changes most significantly, in the tool T, and that the position of the camera  141  at the time of imaging a region B is Zd. 
         [0040]    The PC  2  calculates a contrast value C from a transferred image inside of the tool T. It is known that generally, the contrast value C is obtained by the following way (see, e.g., JP-A-11-283035). 
         [0000]    
       
         
           
             
               
                 
                   C 
                   = 
                   
                     
                       
                         ∑ 
                         
                           y 
                           = 
                           1 
                         
                         
                           n 
                           - 
                           1 
                         
                       
                        
                       
                         
                           ∑ 
                           
                             x 
                             = 
                             1 
                           
                           
                             m 
                             - 
                             1 
                           
                         
                          
                         
                           
                             { 
                             
                               
                                 g 
                                  
                                 
                                   ( 
                                   
                                     
                                       x 
                                       + 
                                       1 
                                     
                                     , 
                                     y 
                                   
                                   ) 
                                 
                               
                               - 
                               
                                 g 
                                  
                                 
                                   ( 
                                   
                                     x 
                                     , 
                                     y 
                                   
                                   ) 
                                 
                               
                             
                             } 
                           
                           2 
                         
                       
                     
                     + 
                     
                       
                         ∑ 
                         
                           y 
                           = 
                           1 
                         
                         
                           n 
                           - 
                           1 
                         
                       
                        
                       
                         
                           ∑ 
                           
                             x 
                             = 
                             1 
                           
                           
                             m 
                             - 
                             1 
                           
                         
                          
                         
                           
                             { 
                             
                               
                                 g 
                                  
                                 
                                   ( 
                                   
                                     x 
                                     , 
                                     
                                       y 
                                       + 
                                       1 
                                     
                                   
                                   ) 
                                 
                               
                               - 
                               
                                 g 
                                  
                                 
                                   ( 
                                   
                                     x 
                                     , 
                                     y 
                                   
                                   ) 
                                 
                               
                             
                             } 
                           
                           2 
                         
                       
                     
                   
                 
               
               
                 
                   [ 
                   
                     Expression 
                      
                     
                         
                     
                      
                     1 
                   
                   ] 
                 
               
             
           
         
       
     
         [0041]    In the expression, g(x, y) represents the luminance of a pixel located at (x, y) on a plane of XY-coordinates. The contrast is calculated for m×n pixels in the tool T. 
         [0042]    In this case, if the region D is located upper (in the Y-axis direction) than the central position of the tool T as illustrated in  FIG. 7B , maximum contrast is obtained when the position Zd corresponding to a timing, at which the camera  141  images the region D before reaching the position Z 2 , is an in-focus position. On the other hand, if the region D is located lower (in the Y-axis direction) than the central position of the tool T as illustrated in  FIG. 7C , maximum contrast is obtained when the position Zd corresponding to a timing, at which the camera  141  images the region D after reaching the position Z 2 , is an in-focus position. Accordingly, in any of these cases, maximum contrast cannot be obtained even if the position Z 2  corresponding to a timing, at which the center of the image is imaged, is an in-focus position. Thus, when the region D most contributing to contrast is deviated from the center of the image, the contrast curve itself illustrated in  FIG. 4  is laterally shifted. Accordingly, an accurate in-focus position cannot be obtained. 
         [0043]    Thus, according to this embodiment, a contrast value C +  is obtained every line, considering the timing of imaging thereof. Then, the arithmetic mean of the obtained contrast values C +  is calculated to thereby obtain the contrast value C of a frame. 
         [0044]      FIG. 8  is a diagram for describing this contrast value calculation processing. In  FIG. 8 , each of timings T zpre , T zcur , and T znext  indicated with symbols ∇ represents a reference position of each frame. In this example, each reference position corresponds to a timing of imaging a leading line. The timing of imaging each pixel of each line differs from that of imaging each of the other pixels thereof. However, for facilitating processing, the timing of imaging each line is set at that of imaging a pixel located at the central position of each line. The timing of imaging each line is behind that T zcur  of imaging the reference position of a current frame by a time t cur , and advanced from the timing T znext  of imaging the reference position of the next frame by a time t next . Accordingly, if the contrast of each line of a current frame and that of each line of the next frame are set at ΔC cur  and ΔC next , respectively, the contrast value C +  of each line of the current frame, which is corrected by a proportional distribution in consideration of the timing of imaging such lines, can be calculated by the following expression. 
         [0000]        C   +   =ΔC   cur   ·k+ΔC   prev ·(1 −k )   [Expression 2]
 
         [0045]    In this expression, k=t next /(t cur +t next ). The value of k can be approximately calculated using Y-coordinate values. Thus, the contrast value can be corrected, based on which of the timing of imaging the previous frame and that of imaging the current frame is closer to the timing of imaging the reference position of the current frame, by obtaining the contrast value C +  of each line of the current frame. Then, the contrast value C of each frame can be calculated from the obtained contrast value C +  of each line as follows. 
         [0000]    
       
         
           
             
               
                 
                   C 
                   = 
                   
                     
                       1 
                       n 
                     
                      
                     
                       
                         ∑ 
                         
                           y 
                           = 
                           1 
                         
                         
                           n 
                           - 
                           1 
                         
                       
                        
                       
                         C 
                         + 
                       
                     
                   
                 
               
               
                 
                   [ 
                   
                     Expression 
                      
                     
                         
                     
                      
                     3 
                   
                   ] 
                 
               
             
           
         
       
     
         [0046]    According to the above embodiment, the contrast value C +  of each line is obtained. However, the image measuring apparatus can be configured such that the contrast value C +  of each pixel is obtained. Besides, when the contrast value C +  of each pixel is obtained, the value of k can be calculated using X-coordinate values and Y-coordinate values. Alternatively, the image measuring apparatus can be configured such that the contrast value C +  of each set of several lines, which is configured like each region R illustrated in  FIG. 8 , is obtained. If the contrast value C +  of each pixel is obtained, accuracy is improved. If the contrast value C +  of each broader region R is obtained, the burden of computation can be alleviated. In addition, the reference position can be set at an intermediate position or the end of a frame, instead of the beginning thereof. 
         [0047]    According to such a method, even when a relatively inexpensive CMOS camera of the rolling shutter type is used as the camera  141 , autofocusing can be performed with good accuracy.