Robust autofocus algorithm for multi-spectral imaging systems

An autofocus metric approach for focusing video images, automatically, based on images taken during a focus sweep in which a focus cell is repositioned for each of the images is provided. The approach includes, given an edge detected image from the focus sweep and an associated focus cell position in the focus sweep, an autofocus engine dividing the edge detected image into sub-images. For each sub-image, the autofocus engine calculates a normalized edge detection strength and compares it to a threshold. Based on the comparison, the autofocus engine determines whether an edge is present in the sub-image. Based on the determinations of edges in the sub-images, the autofocus engine calculates an autofocus metric associated with the given focus cell position. The autofocus engine provides the autofocus metric together with autofocus metrics associated with other focus cell positions to focus the video images.

BACKGROUND

Autofocus systems rely on one or more sensors to determine correct focus. Data collected from an autofocus sensor is used to control an electromechanical system that adjusts the focus of an optical system of a camera. When an image is taken of a subject that is on the ground by the camera that is also on the ground, the subject may in focus while the background is out of focus. This is because the range from the camera and to the subject is different than the range from the camera to the background. In an air-to-ground application, ranges from an airborne camera to the ground and to people and objects on the ground are nearly the same. As such, the challenge to autofocusing images taken from the air is focusing the entire image and not just a portion. Other challenges, which are particularly prevalent to surveillance applications, include autofocusing images quickly and low light conditions.

SUMMARY

In accordance with an example, a method for focusing video images, automatically, based on images taken during a focus sweep in which a focus cell is repositioned for each of the images is provided. The method includes, in an autofocus engine, given an edge detected image from a focus sweep and an associated position of a focus cell in the focus sweep, dividing the edge detected image into sub-images. The method further includes for each sub-image, calculating a normalized edge detection strength of a subject sub-image and comparing the normalized edge detection strength of the subject sub-image to a threshold. The method further includes determining, based on the comparison, an edge is present in the subject sub-image and calculating, based on the determinations of edges in the sub-images, an autofocus metric associated with the given position of the focus cell. The method further includes providing the autofocus metric together with autofocus metrics associated with other positions of the focus cell to focus video images.

In accordance with another example, a system for focusing video images, automatically, based on images taken during a focus sweep in which a focus cell is repositioned for each of the images is provided. The system includes memory having computer executable instructions thereupon and at least one interface receiving an edge detected image from a focus sweep and an associated position of a focus cell in the focus sweep. The system further includes an autofocus engine coupled to the memory and the at least one interface. The computer executable instructions, when executed by the autofocus engine, cause the autofocus engine to divide the edge detected image into sub-images. The autofocus engine further caused to calculate, for each sub-image, a normalized edge detection strength of a subject sub-image and compare the normalized edge detection strength of the subject sub-image to a threshold. The autofocus engine further caused to determine, based on the comparison, an edge is present in the subject sub-image and to calculate, based on the determinations of edges in the sub-images, an autofocus metric associated with the given position of the focus cell. The autofocus engine further caused to provide the autofocus metric together with autofocus metrics associated with other positions of the focus cell to focus video images.

In accordance with yet another example, a tangible computer-readable storage medium having computer readable instructions stored therein for focusing video images, automatically, based on images taken during a focus sweep in which a focus cell is repositioned for each of the images is provided. The computer readable instructions, when executed by one or more processors, cause the one or more processors to, given an edge detected image from a focus sweep and an associated position of a focus cell in the focus sweep, divide the edge detected image into sub-images. The one or more processors further caused to calculate, for each sub-image, a normalized edge detection strength of a subject sub-image and compare the normalized edge detection strength of the subject sub-image to a threshold. The one or more processors further caused to determine, based on the comparison, an edge is present in the subject sub-image and to calculate, based on the determinations of edges in the sub-images, an autofocus metric associated with the given position of the focus cell. The one or more processors further caused to provide the autofocus metric together with autofocus metrics associated with other positions of the focus cell to focus video images.

In some examples, any of the aspects above can include one or more of the following features.

In other examples of the method, calculating the normalized edge detection strength of the subject sub-image having pixel values includes selecting a maximum pixel value found in the subject sub-image and a minimum pixel value found in the subject sub-image. The examples of the method further include forming a ratio of a difference of the maximum pixel value and minimum pixel value to a sum of the maximum pixel value and minimum pixel value, the ratio being a contrast measure, and multiplying the contrast measure with a mean of the pixel values in the sub-image resulting in a normalized and weighted edge detection strength of the subject sub-image.

In some examples of the method, calculating the autofocus metric includes averaging the normalized edge detection strengths of sub-images having edges present.

Other examples of the method further include selecting a position of the focus cell based on the autofocus metrics and repositioning the focus cell to the selected position to focus the video images.

In some examples of the method, selecting the position of the focus cell includes creating a model of autofocus metrics and positions of the focus cell from the calculated autofocus metrics and associated positions of the focus cell and selecting a best position of the focus cell from the model.

In other examples of the method, the model is a non-linear regression fit of the calculated autofocus metrics to the model.

Some examples of the method further include for each image taken during a focus sweep, cropping a subject image into a region of interest and reducing white noise of the region of interest resulting in a filtered image. The examples of the method further include detecting edges in the filtered image resulting in an edge detected image associated with a position of the focus cell in the focus sweep.

Other examples of the method further include capturing images, during a focus sweep, in wavelengths selected from a group consisting of Day Television (DTV), Near Infrared (NIR), SWIR-Short Wave Infrared (SWIR), Mid Wave Infrared (MWIR), and Long Wave Infrared (LWIR).

DETAILED DESCRIPTION

In the description that follows, like components have been given the same reference numerals, regardless of whether they are shown in different examples. To illustrate an example(s) of the present disclosure in a clear and concise manner, the drawings may not necessarily be to scale and certain features may be shown in somewhat schematic form. Features that are described and/or illustrated with respect to one example may be used in the same way or in a similar way in one or more other examples and/or in combination with or instead of the features of the other examples.

FIG. 1shows an example of an aerial imaging platform100(e.g., a drone) flying over the ground105and performing surveillance. The aerial imaging platform100has an imaging system110for surveying people and objects on the ground105. The imaging system110includes an imaging sensor115, focus cell120, and autofocus engine125. The imaging sensor115take images, for example, video images in the wavelengths of Day Television (DTV), Near Infrared (NIR), SWIR-Short Wave Infrared (SWIR), Mid Wave Infrared (MWIR), or Long Wave Infrared (LWIR).

The focus cell120focuses the images taken by the image sensor115. The focus cell120is configured to change positions with each focus cell position focusing an image differently. This is known as a “focus sweep.” The autofocus engine125controls the position of the focus cell120by providing the focus cell120with a selected focus cell position. The autofocus engine125, itself, may be controlled by an operator (e.g., the operator of the drone100). In a “push-to-focus” application, the operator, wanting to focus an out of focus image, pushes a button and the autofocus engine125focuses the image.

In an autofocus metric approach (and its examples described herein), the autofocus computes an autofocus metric associated with each focus cell position and selects the best focus cell position based on the computed metrics. Operation of the autofocus engine125implementing examples of the autofocus metric approach are described below with reference toFIGS. 2A-2C.

FIG. 2Ashows a first image205taken at a first position of the focus cell120and a second image210taken at a second focus cell position different from the first focus cell position. The first and second images205,210are two of several images taken at different focus cell positions during a focus sweep. An edge detector processes the first image205and second image210resulting in an edge detected first image215and edge detected second image220, respectively, shown inFIG. 2B. Any one of a number of edge detectors maybe used, for example, a Sobel edge detector. For the sake of describing examples of the autofocus metric approach and for readability, the edge detected first image215is referred to as the “in-focus-image” and the edge detected second image220is referred to as the “out-of-focus-image.”

The autofocus image divides the in-focus-image215and the out-of-focus-image220into sub-images225,230called “patches.” In a convenient example of the autofocus metric approach, the size of the patches is selected so that each patch contains one or zero detected edges. In another example, the size of the patches is selected to reduce the impact of glints/bright lights in low flux (light) conditions.

Before continuing the explanation of the autofocus metric approach, consider an example of an image in which a portion of an image has high contrast. Because of this high contrast area, a high edge detection strength may be calculated for an otherwise out-of-focus-image. In turn, this may lead to the wrong conclusion that the image is in focus when it is not. In other words, the edge detection strength calculation may be dominated by a portion of an image and may not be representative of the entire image. This condition is not desirable and it can defeat conventional autofocus approaches.

To reduce dependence on parts of an image that have high contrast but do not have edges and on other parts that are benign, the autofocus engine125(FIG. 1) divides the in-focus-image215and the out-of-focus-image220into sub-images225,230called “patches.” The autofocus engine125then assigns a “local” edge detection strength (edge contrast) to each patch. The autofocus engine125derives an autofocus metric based on these local values for the sub-images. In contrast, conventional autofocus approaches based contrast enhancement, derive their metrics from an entire image.

In a convenient example of the autofocus metric approach, the size of the patches is selected so that each patch contains one or zero detected edges. In another example, the size of the patches is selected to reduce the impact of glints/bright lights in low flux (light) conditions. In a yet another convenient example of the autofocus metric approach, given pixel values of a patch, the autofocus engine125calculates a normalized edge detection strength for the patch by selecting a maximum pixel value and minimum pixel value found in the patch. The autofocus engine125forms a ratio of a difference of the maximum pixel value and minimum pixel value to a sum of the maximum pixel value and minimum pixel value. The ratio is a measure of contrast. The autofocus engine125multiplies the contrast measure with a mean of the pixel values in the patch resulting in a normalized and weighted edge detection strength of the patch.

The foregoing action scales all local patch values so that a local ‘weak’ (low contrast, but sharp) contributes equally to a local ‘strong’ (high contrast and sharp). A sharp edge is defined as a transition that occurs from a low value region of the image to a high value region in one or a few pixels. The fewer the pixels in the width of the border or transition boundary between a low and high region of the image, the ‘sharper’ the weight. The goal of focusing is to ‘sharpen’ all the borders, which is the difference between ‘in-focus’ and ‘out-of-focus’ in the usual sense.

The autofocus engine125compares the normalized edge detection strength of a given patch with a threshold. Using the threshold, the autofocus engine125discriminates between patches with detected edges and patches without detected edges. In some examples of the autofocus metric approach, a user defines the threshold and inputs the threshold in the autofocus engine125using an input device such as a keyboard or mouse. In other examples of the autofocus metric approach, the autofocus engine125or other component adjusts the threshold based on application.

In the example ofFIG. 2C, the autofocus engine125(FIG. 1) determines that 99% of the patches225of the in-focus-image215include edges and 1% do not. In comparison, the autofocus engine125determines that 20% of the patches230of the out-of-focus-image220include edges and 80% do not. The autofocus engine125computes a first autofocus metric for the first focus cell position based on patches225determined to have edges. The autofocus engine125computes a second autofocus metric for the second focus cell position based on patches230determined to have edges.

The autofocus engine125provides the first and second autofocus metrics, and the autofocus metrics calculated for other focus cell positions in the focus sweep to be used in determining the “best” focus cell position. In turn, the focus cell120moves to the best focus cell position to focus images. A convenient example of the autofocus engine125selects the best focus cell position based on the computed autofocus metrics and associated focus cell positions. (The selection procedure is described in greater detail immediately below.) The autofocus engine125repositions the focus cell120to the best focus cell position to focus images.

FIG. 3Ashows data points (denoted in the figure as plus signs) generated by the autofocus engine125(FIG. 1) as the focus cell120(FIG. 1) sweeps from left to right at a constant rate and images are collected at discrete times. Each data point represents an autofocus metric (shown on the Y-axis) calculated for a given focus cell position (shown on the X-axis), as described above with reference toFIGS. 2A-2C.

The autofocus engine125creates a model300from the autofocus metrics and associated focus cell positions. The model300represents how image sharpness (degree of focus) is expected to change as the position of the focus cell120changes, based on physics. As such, the model300is theoretical. In a convenient example of the autofocus metric approach, the model300is a non-linear regression fit. The “peak” of the model, referenced in the figure as305, represents the best focus cell position. The autofocus engine125provides the best focus cell position305to the focus cell120to focus images.

The number of autofocus metrics (data points) computed by the autofocus engine125from which to build the model300, may be selected based on a region of interest and patch size. A typical patch size of between 7×7 to 20×20 is selected to minimize the number of edges in any patch. Ideally a single patch operates on a single distinctive edge. In a preferred example, a patch size of 10×10 is selected. In some examples of the autofocus metric approach, the number of autofocus metrics computed by the autofocus engine125is selected so that the best focus cell position is selected within a certain amount of time, e.g., one second or two seconds. This is particularly advantageous for a “push-to-focus” feature in which an operator expects a blurry image to come into focus shortly after pressing a focus button.

FIG. 3Bshows an example of the autofocus metric approach used in a low light imaging condition in which there is very low signal. Such an imaging condition is a challenge for conventional autofocus approaches. The data points are more scattered than compared to the example ofFIG. 3A. The increased scattering represents increased noise in the measurements used to calculate autofocus metrics. The autofocus engine125(FIG. 1) finds a model315(theoretical best curve) that goes through the data points and selects the best focus cell position (shown as reference number315) from the model315.

In another example of the autofocus metric approach, for each image taken during a focus sweep, the autofocus engine125crops a subject image into a region of interest. Generally, the central portion of an image contains the object of interest. Border regions of the image provide context information. The objective is to have the central region of interest in sharp focus, not to be skewed by border region objects. Beneficially, cropping the image to the central region ensures that the autofocus gives best focus of the central region.

The autofocus engine125then reduces the white noise of the region of interest resulting in a filtered image. This denoising procedure reduces the random pixel noise in images taken with low signal. The autofocus engine125detects edges in the filtered image, e.g., by applying Sobel or Laplace edge detection. The result is an edge detected image associated with a position of the focus cell120in the focus sweep. The autofocus engine125computes autofocus metrics from the edge detected, as described above with reference toFIG. 2A-2C.

FIG. 4Ashows a convenient example of the autofocus engine125(FIG. 1) implementing an example of the autofocus metric approach450shown inFIG. 4B. The autofocus engine125includes an image dividing module405, normalized edge strength calculating module410, comparing module415, and autofocus metric calculating module420each communicatively coupled to the other as shown. It should be appreciated that other examples of the autofocus engine125may include more or fewer modules than shown.

Provided with edge detected image401and associated focus cell position402as input, the image dividing module405divides (455) the edge detected image401into sub-images425. For each of the sub-images425, the normalized edge strength calculating module410calculates (460) a normalized edge detection strength430. The comparing module415compares (465) the normalized edge detection strength411of a subject sub-image to a threshold.

Based on the comparison, the comparing module415determines (470) whether an edge is present in the subject sub-image and provides a determination435. Based on the determination of an edge435in the subject sub image and the determinations of edges in other sub-images, the autofocus metric calculating module420, calculates (475) an autofocus metric440associated with the focus cell position135. The autofocus engine125provides (480) the focus cell position402and autofocus metric440to focus images.

The above-described systems and methods can be implemented in digital electronic circuitry, in computer hardware, firmware, and/or software. The implementation can be as a computer program product (i.e., a computer program tangibly embodied in an information carrier medium). The implementation can, for example, be in a machine-readable storage device for execution by, or to control the operation of, data processing apparatus. The implementation can, for example, be a programmable processor, a computer, and/or multiple computers.

In one example, a computer program can be written in any form of programming language, including compiled and/or interpreted languages, and the computer program can be deployed in any form, including as a stand-alone program or as a subroutine, element, and/or other unit suitable for use in a computing environment to carry out the features and functions of various examples discussed herein. A computer program can be deployed to be executed on one computer or on multiple computers at one site.

Method steps or operations can be performed as processes by one or more programmable processors executing a computer program to perform functions of various examples by operating on input data and generating output. Method steps can also be performed by and an apparatus can be implemented as special purpose logic circuitry. The circuitry can, for example, be a field programmable gate array (FPGA) and/or an application specific integrated circuit (ASIC). Modules, subroutines, and software agents can refer to portions of the computer program, the processor, the special circuitry, software, and/or hardware that implements that functionality.

The autofocus engine125may comprise one or more processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor receives instructions and data from a read-only memory or a random access memory or both. The elements of a computer may comprise a processor for executing instructions and one or more memory devices for storing instructions and data. Generally, a computer can include, can be operatively coupled to receive data from and/or transfer data to one or more mass storage devices (e.g., a memory module) for storing data (e.g., magnetic, magneto-optical disks, or optical disks). The memory may be a tangible non-transitory computer-readable storage medium having computer-readable instructions stored therein for processing images, which when executed by one or more processors (e.g., autofocus engine125) cause the one or more processors to carry out or implement the features and functionalities of various examples discussed herein.

To provide for interaction with a user, the above described techniques can be implemented on a computing device having a display device. The display device can, for example, be a cathode ray tube (CRT) and/or a liquid crystal display (LCD) monitor, and/or a light emitting diode (LED) monitor. The interaction with a user can, for example, be a display of information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computing device (e.g., interact with a user interface element). Other kinds of devices can be used to provide for interaction with a user. Other devices can, for example, be feedback provided to the user in any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback). Input from the user can, for example, be received in any form, including acoustic, speech, and/or tactile input.

The system may be coupled to and/or include clients and servers. A client and a server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computing devices and having a client-server relationship to each other.

Communication networks may include packet-based networks, which can include, for example, the Internet, a carrier internet protocol (IP) network (e.g., local area network (LAN), wide area network (WAN), campus area network (CAN), metropolitan area network (MAN), home area network (HAN)), a private IP network, an IP private branch exchange (IPBX), a wireless network (e.g., radio access network (RAN), 802.11 network, 802.16 network, general packet radio service (GPRS) network, HiperLAN), and/or other packet-based networks. Circuit-based networks may include, for example, the public switched telephone network (PSTN), a private branch exchange (PBX), a wireless network (e.g., RAN, Bluetooth, code-division multiple access (CDMA) network, time division multiple access (TDMA) network, global system for mobile communications (GSM) network), and/or other circuit-based networks.

The autofocus engine125may include, for example, a computer, a computer with a browser device, a telephone, an IP phone, a mobile device (e.g., cellular phone, personal digital assistant (PDA) device, laptop computer, electronic mail device), and/or other communication devices. The browser device includes, for example, a computer (e.g., desktop computer, laptop computer) with a World Wide Web browser (e.g., INTERNET EXPLORER® available from Microsoft Corporation, of Redmond, Wash.). The mobile computing device includes, for example, a BLACKBERRY® provided by Research In Motion Limited of Waterloo, Ontario, Canada.

“Comprise,” “include,” and/or plural forms of each are open ended and include the listed parts and can include additional parts that are not listed. “And/or” is open ended and includes one or more of the listed parts and combinations of the listed parts.

Although the above disclosure discusses what is currently considered to be a variety of useful examples, it is to be understood that such detail is solely for that purpose, and that the appended claims are not limited to the disclosed examples, but, on the contrary, are intended to cover modifications and equivalent arrangements that are within the spirit and scope of the appended claims.