The disclosed embodiments relate to digital image processing for identification of pills, and specifically to the use and digital analysis of pill imprints to facilitate identification of pills.
Pills of many shapes, sizes and colors are available as both prescription and non-prescription medications. In the United States, the physical identifiers of solid dosage pharmaceuticals are approved by the Federal Drug Administration. Ideally, no two pills are approved to have exactly the same identifiers. Thus, pills are approved to each have a unique combination of shape, size, color, imprint (i.e., characters or numbers printed on the medication), and/or scoring. Nevertheless, despite the fact that every type of FDA-approved pill is indeed intended to be unique, the differences between pills is sometimes subtle. For example, two pills of the same shape but slightly different colors and/or sizes may easily be confused by a patient. Pills normally differentiated by imprint may not appear to be different at all, for example, if the imprints are not readable because the pills are face-down or the patient has poor vision. Such concerns are exacerbated by the actions of patients who may not be fully coherent or alert.
Patients are not the only individuals who have a need to quickly and easily identify pills. Relatives or caretakers of patients may also have such a need. Their need may stem from their responsibility to provide the correct pills to the patient, or simply from a desire to verify that the patient has taken the correct pills. Hospitals may have a need to quickly identify each of a collection of pills that a person brings from home or that may have been ingested by a child admitted for accidental ingestion of medication. Pharmacies have an interest in ensuring that correct pills are dispensed. Insurance companies may even have an interest in monitoring medication adherence, ensuring that correct pills are dispensed to and taken regularly by the insured. In other words, many parties have an interest in verifying the identity of pills, whether the pills are identified individually or as a collection of various pills.
Pills can be identified using various photographic and image processing methods. For example, a digital image of a pill or collection of pills can be taken, and then image processing methods can be used to determine how many pills are in the image, the location and boundaries of the pills in the image, and to assign pixels in the image to a potential pill for identification. This process of segmentation ideally results in every pixel in the image either being assigned to a pill with well-defined and accurate boundaries or being disregarded as not belonging to any pill. Once pixels are assigned, the accumulated pixels for a given pill can be analyzed to determine the characteristics of the pill (e.g., its size, shape, color and imprint).
Practical and accurate segmentation methods and their use in pill identification are described, for example, in U.S. patent application Ser. No. 13/490,510, filed Jun. 7, 2012, the entirety of which is incorporated herein by reference. Color correction methods used during pill identification are described, for example, in U.S. patent application Ser. No. 13/665,720, filed Oct. 31, 2012, the entirety of which is also incorporated herein by reference.
Despite efforts to identify pills based only on size, shape and color, some pills with similar sizes, shapes and/or colors require analysis of yet an additional characteristic, such as pill imprint, in order to accurately differentiate between the similar pills. Thus, while size, shape and/or color may be used to at least narrow the list of potential matches for a pill's identification, analysis of a pill's imprint may be necessary to achieve a sufficient level of confidence that a pill has been identified correctly. Alternatively, analysis of a pill imprint could also be used as the primary tool for identifying a pill.
In a digital image of one or more pills, however, the pills to be identified may be rotated or positioned haphazardly so as to render imprint analysis difficult. Accordingly, there exists a need for methods that can accurately identify a pill using imprint analysis regardless of the rotation of the pill.
In the following detailed description, reference is made to the accompanying drawings, which form a part hereof, and in which is shown by way of illustration specific embodiments that may be practiced. It should be understood that like reference numbers represent like elements throughout the drawings. Embodiments are described with sufficient detail to enable those skilled in the art to practice them. It is to be understood that other embodiments may be employed, and that various structural, logical, and electrical changes may be made without departing from the spirit or scope of the invention.
A pill is a tablet, capsule, caplet or other solid unit of medication, prescription or over-the-counter, that is taken orally. Pills vary in appearance by size, shape and imprint, among other features. Pill identification through digital imaging and signal processing takes advantage of these differences in pill appearances to identify a pill. For example, an individual can use a mobile device such as a smartphone to image one or more pills. Software, resident either on the smartphone and/or remote from the smartphone, processes the image to segment the pills, identify features of each imaged pill and then compare the identified features of each pill with a database of pill features in order to determine the identity of each pill. The pill database includes an indication of pill imprint for each pill in the database. Pill imprints are unique for each type of pill. Thus, when one or more pills are imaged, the imprint on each pill may be compared with the imprint patterns stored in the database. A match in imprint pattern is one step in identifying each pill.
A method of identifying a pill using the pill's imprint pattern is summarized in
Before method 100 can be applied, a database of composite imprints must be created. A composite imprint is essentially a two-dimensional probability histogram that a pixel from a pill image is part of an imprint. Thus, a composite imprint quantifies the likelihood that pixels in an image are part of an imprint for a given pill. In order to create a composite imprint, individual imprints of two or more pills of the same type are obtained and combined. Two or more individual imprints are combined so that noise existent in an imaged individual imprint and not in a second individual imprint can be canceled out, as explained below. Pill imprints are often difficult to see in normal light, and while imprint edges in digital images can be detected using standard edge-finding techniques (as used, e.g., in computer vision technologies), the detected edges may not always be complete or may include significant noise. By combining multiple individual imprints into a composite imprint, the imprint edges can be completed and noise can be reduced.
As an example,
By iteratively using standard adaptive threshold edge-finding techniques, the edges of the imprint on the pill can be detected. For example,
Although the pill's imprint is clearly visible in both the fractional individual imprint illustrated in
Multiple imprints (either fractional individual imprints or binary individual imprints) are combined by first rotationally aligning the imprints about a center of the pill. This is done by selecting a first or seed individual imprint. The seed individual imprint may be randomly selected from among the available individual imprints for a given pill or may be purposefully selected based on criteria relating to the individual imprint's quality or other measures of the imprint's fitness as a seed imprint. Then, the center of the seed imprint is determined. The center of the seed imprint can either be at the geometric center of the seed image or at the center of mass of the pill's bounding contour. If the imaged pill is symmetric in multiple dimensions, then the geometric center is used. This is determined by bounding the pill's contour with a minimum-area rectangle and then using the center of the rectangle as the center of the seed imprint.
Once the seed imprint is selected and its rotational center is chosen, a second individual imprint of the same type (either a fractional individual imprint or a binary individual imprint) is selected and its center is also computed. The two imprints are then overlapped such that their computed centers match. The second image is then rotated with respect to the seed image. The rotated angle that results in the best overlap of the two images is determined. Additionally, for each rotation, the second image may be shifted in one or more directions in order to improve the overlap of the two imprint patterns.
As an example, the second image can be rotated with respect to the seed image in increments of a predetermined number of degrees (e.g., two degrees for each rotation). After each rotation, the degree of overlap of the two images is determined. Additionally, after each rotation, the second image can be shifted by one or more pixels in one or more allowed directions, with each shift being tested for its degree of overlap. Then, the second image is re-centered about the seed image and the second image is rotated an additional number of degrees in order to test the degree of overlap at that rotation. At each rotation, the second image is shifted. Thus, for each rotation, the degree of overlap is tested for the un-shifted images as well as for one or more shifted images. The best overlap represents the rotation and shift that best matches the imprints in the images.
Because the two imprint patterns are from the same type of pill, the expectation is that, with appropriate rotation and shifting, the two imprint patterns should have a high degree of overlap. The degree of overlap of the two imprint patterns can be quantified in a variety of ways. For example, a sum of squared pixel-wise differences technique can be used, where the difference in values of overlapping pixels is used to determine the rotation and shift that yields the best possible match. When using a sum of squared pixel-wise differences technique, each comparison (corresponding to a specific rotation and shift) will result in a number. The comparison that results in the lowest number indicates that the second imprint has been rotated and shifted to align with the seed imprint.
Other techniques can be used to find the best possible match between imprints. Instead of using a sum of squared pixel-wise differences technique, other techniques that could be used include a sum of pixel-wise log likelihoods technique, a correlation technique, and a correlation coefficient technique, as are known in the art.
As an example,
As explained above, fractional individual imprints may be used instead of binary individual imprints.
Once at least two individual imprints of a same pill type have been matched, the imprints can be added together to create a combined imprint image. The combined imprint image is then normalized to create a composite imprint. The resulting image can be considered a two-dimensional probability histogram of the imprint. A composite imprint formed by the two binary imprints illustrated in
Composite imprints are added to a database of composite imprints and are used to help identify unknown pills. Pills requiring identification are imaged in the same way as described above. Returning again to
In order to reduce the number of composite imprints to which the unknown pill must be compared, other characteristics of the unknown pill may also be determined and used to narrow the pool of possible pill types. For example, an unknown pill that is determined to be white and circular-shaped need only have its imprint compared with composite imprints corresponding to pills that are also white and circular-shaped.
The imprint matching and pill identification method described above includes many benefits. A primary benefit of the imprint matching process is that the process does not rely on character recognition. Instead of attempting to recognize characters, the described process identifies patterns and then finds matching patterns, regardless of the shape or type of symbol used in the imprint. Additionally, the process does not require that all pills be oriented in the same direction prior to imaging. Because multiple pills are used to build the composite imprints, the process is noise tolerant and doesn't require “perfect” or unblemished pills.
A further benefit of the disclosed process is that the fractional individual or binary individual imprints obtained from pills can also convey surface texture information for the associated pill (e.g., whether the pill's surface is smooth or rough). This type of information can also be used to help identify an unknown pill.
Methods 100 and 700 can be implemented as either hardware or software, or a combination thereof. A mobile device 800, as illustrated in
System 850 includes an imprint matching module 855. The imprint matching module 855 performs methods 100 and 700. System 850 may also include other modules used to identify the color, size and shape of the imaged pills. As an example, system 850 and the modules used within system 850 may be implemented as an application on a smartphone.
The above description and drawings are only to be considered illustrative of specific embodiments, which achieve the features and advantages described herein. Modifications and substitutions to specific process conditions can be made. Accordingly, the embodiments of the invention are not considered as being limited by the foregoing description and drawings, but is only limited by the scope of the appended claims.