Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides an image feature extraction method, which may include the following steps:
step 101: and carrying out edge detection on the image to obtain a contour image.
In an actual application scene, edge detection can be performed on an image by adopting a Sobel operator, a Prewitt operator and the like to obtain a contour image. The contour image is a binary image.
Step 102: and dividing the contour image to obtain a plurality of contour sub-images.
Step 103: for each contour sub-image: the centroid of the contour sub-image is determined.
Step 104: the distance of each pixel point of the contour sub-image from the centroid is calculated.
Step 105: counting the number of pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center according to the distance between the pixel point and the mass center and a plurality of other pixel points corresponding to the pixel point; and the distance between the pixel point and any other corresponding pixel point is the pixel distance.
In consideration of the fact that the relevance between other pixel points adjacent to the pixel point and the pixel point is large, in an actual application scene, the pixel distance is smaller than a specified relevance threshold value. That is, the image feature extraction process only focuses on other pixel points whose corresponding pixel distance is within the relevant threshold.
The method includes the steps that a contour image is divided, and spatial information of pixel points is fused into image characteristics; meanwhile, in the statistical process, the information of other pixel points which are away from the pixel points by the pixel distance is considered, and the information of adjacent pixel points can be blended into the image characteristics. Because the obtained image features are fused with the spatial information of the pixel points and the information of the adjacent pixel points, the method can describe the image more accurately, and further can improve the accuracy of image identification.
In an embodiment of the present invention, step 102 specifically includes:
a1: and determining a rectangular bounding box corresponding to the outline image.
A2: and dividing the contour image into a plurality of contour sub-images according to a preset division threshold value and the rectangular bounding box.
Wherein the division threshold may be predetermined empirically by the user.
A2 specifically comprises: dividing the contour image into n contour sub-images by taking W/n as a unit; wherein the size of the rectangular bounding box is a × b, W = max (a, b), and n is used to characterize the partition threshold.
The contour image is divided according to the rectangular bounding box corresponding to the contour image, and in an actual scene, the contour image can be divided in other modes, for example, the contour image is divided into a plurality of contour sub-images according to a horizontal line passing through the centroid of the contour image.
The method can divide the outline image uniformly through the rectangular bounding box so as to blend the spatial information of the outline image into the image characteristics.
In one embodiment of the invention, the method further comprises:
determining a rectangular bounding box corresponding to the contour image;
determining the minimum value in the distances between the pixel point corresponding to the contour image and the centroid;
determining the maximum value in the distances between the pixel point corresponding to the contour image and the centroid;
standardizing the distance between each pixel point and the centroid according to the rectangular bounding box, the maximum value and the minimum value;
according to the distance between each pixel point and the centroid and a plurality of other pixel points corresponding to each pixel point, the number of the pixel points corresponding to the pixel distance and the distance between the pixel point and the centroid is counted, and the method comprises the following steps:
and counting the number of the pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center according to the standardized distance between the pixel point and the mass center and a plurality of other pixel points corresponding to the pixel point.
The distance difference between different pixel points and the centroid is large, the distance between the pixel points and the centroid is standardized, and calculation can be simplified.
In an embodiment of the present invention, the counting the number of pixels corresponding to the pixel distance and the distance between the pixel point and the centroid according to the distance between the pixel point and the centroid and a plurality of other pixels corresponding to each pixel point includes:
determining whether other pixel points exist on the upper side or the lower side or the left side or the right side of the current pixel point, wherein the distance between the other pixel points and the center of mass is equal to the distance between the current pixel point and the center of mass; the distance between the current pixel point and other pixel points is the current pixel distance;
if yes, adding 1 to the number of pixel points corresponding to the distance between the current pixel and the centroid;
the current pixel point is any pixel point of the contour sub-image, and the current pixel distance is any one of a plurality of preset pixel distances.
In the embodiment of the invention, other pixel points are searched by adopting a four-neighborhood method, namely the upper side, the lower side, the left side and the right side of the current pixel point are concerned. In an actual application scene, other pixel points can be searched by adopting an eight-neighborhood method, namely whether other pixel points exist on the upper side or the lower side or the left side or the right side or the upper left side or the lower left side or the upper right side or the lower right side of the current pixel point is determined.
As shown in fig. 2, an embodiment of the present invention provides an image feature extraction method, including the following steps:
step 201: and carrying out edge detection on the image to obtain a contour image.
And (5) carrying out edge detection on the image by using a Sobel operator to obtain a contour image.
Step 202: and determining a rectangular bounding box corresponding to the outline image.
The size of the rectangular bounding box is a b, and a > b.
Step 203: and dividing the contour image into a plurality of contour sub-images according to a preset division threshold and the rectangular bounding box.
Dividing the contour image into n contour sub-images by taking a/n as a unit; wherein n is used to characterize the partition threshold.
Step 204: for each contour sub-image: the centroid of the profile sub-image is determined.
Pixel point b of contour subimage i Has the coordinates of (x) i ,y i );
Calculating the centroid c (x) of the profile sub-image according to the formula (1) and the formula (2) c ,y c )。
And N is used for representing the number of pixel points of the contour sub-image.
Step 205: the distance of each pixel point of the contour sub-image from the centroid is calculated.
d (bi, c) is used for representing the distance between the pixel point bi and the centroid c.
The distance between the pixel point corresponding to each contour sub-image and the centroid forms a distance matrix.
Step 206: and determining the minimum value in the distances between the pixel point corresponding to the contour image and the centroid.
Step 207: and determining the maximum value in the distances between the pixel points corresponding to the contour images and the centroid.
Step 208: the distance of each pixel point from the centroid is normalized according to the rectangular bounding box, the maximum value and the minimum value.
The distance of the pixel point from the centroid is normalized according to equation (4).
Wherein norm _ dis is used for representing the distance between each pixel point and the centroid after standardization, dis is used for representing the distance between the pixel point and the centroid, dis min For characterizing the minimum, dis, of the distances between the pixel point corresponding to the profile image and the centroid max The maximum value of the distances between the corresponding pixel points of the outline image and the centroid is represented, W is used for representing the maximum side length of the rectangular bounding box, and in the embodiment of the invention, W = a.
Step 209: and counting the number of the pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center according to the standardized distance between the pixel point and the mass center and a plurality of other pixel points corresponding to the pixel point.
And the distance between the pixel point and any other corresponding pixel point is the pixel distance.
And (2) sequentially scanning each pixel point of the contour subimage aiming at each pixel distance, and respectively taking each pixel point as a current pixel point to execute the following steps: determining whether other pixel points exist on the upper side or the lower side or the left side or the right side of the current pixel point, wherein the distance between the other pixel points and the center of mass is equal to the distance between the current pixel point and the center of mass; the distance between the current pixel point and other pixel points is the current pixel distance; if yes, adding 1 to the number of the pixel points corresponding to the distance between the current pixel and the centroid, and if not, scanning the next pixel point.
The current pixel point is any pixel point of the contour sub-image, and the current pixel distance is any pixel distance in the pixel distances.
In the embodiment of the present invention, the number of pixels corresponding to the distances between different pixel points and the centroid needs to be counted for each pixel distance. For example, the pixel distance includes: 1. 3, 5 and 7, the distance between the pixel point and the centroid comprises: 1. 2, 3.. 50, the method needs to count the number of pixel points when the pixel distances are 1, 3, 5 and 7 respectively and the distances between the pixel points and the centroid are 1-50 respectively. For example, when the distance between a pixel and the centroid is 1-50, counting the number of corresponding pixel points; counting the number of corresponding pixel points when the pixel distance is 3 and the distance between the pixel point and the centroid is 1-50;
in the process of scanning each pixel point of the contour subimage, each pixel point can be scanned according to the arrangement sequence of the pixel points in the distance matrix, so that the problem that the statistical result is inaccurate due to errors in the statistical process is avoided.
The number of pixels corresponding to the pixel distance and the distance between the pixel point and the centroid can be expressed as a matrix of K rows and M columns, wherein the pixel distance corresponding to each row is different, and the distance between the pixel point corresponding to each column and the centroid is different. From this matrix, a distance autocorrelation map can be generated. In the process of image recognition, the similarity of the two images can be determined by comparing the corresponding distance autocorrelation graphs of the profile sub-images.
As shown in fig. 3, an embodiment of the present invention provides an image processing method, including:
step 301: carrying out edge detection on an image to be identified to obtain a contour image;
step 302: dividing the contour image to obtain a plurality of contour sub-images;
step 303; for each contour sub-image: determining the mass center of the contour sub-image;
step 304: calculating the distance between each pixel point of the contour sub-image and the centroid;
step 305: counting the number of pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center according to the distance between the pixel point and the mass center and a plurality of other pixel points corresponding to the pixel point; the distance between a pixel point and any other corresponding pixel point is the pixel distance;
step 306: constructing a distance autocorrelation graph corresponding to the contour sub-image according to the pixel distance, the distance between the pixel point and the mass center, and the number of pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center;
step 307: comparing a plurality of distance autocorrelation graphs corresponding to the image to be recognized with a plurality of distance autocorrelation graphs of the template image acquired in advance respectively, and determining the similarity of the image to be recognized and the template image.
And establishing a coordinate system by taking the pixel distance, the distance between the pixel point and the mass center, and the number of pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center as coordinate axes to obtain a distance autocorrelation graph.
As shown in fig. 4, the simulated search effect graph based on the distance autocorrelation graph, and as shown in fig. 5, the simulated search effect graph based on the centroid distance histogram. As can be seen from comparison between FIG. 4 and FIG. 5, the simulation retrieval based on the distance autocorrelation graph has high accuracy and better effect. That is to say, "the number of pixels corresponding to the pixel distance and the distance between the pixel point and the centroid" extracted from the image takes into account the spatial information of the pixels and the information of other adjacent pixels, so that the accuracy of image description is improved, and the accuracy of image recognition is further improved.
As shown in fig. 6, an image feature extraction device includes:
a detection unit 601 configured to perform edge detection on the image to obtain a contour image;
a dividing unit 602 configured to divide the contour image to obtain a plurality of contour sub-images;
a statistics unit 603 configured to, for each contour sub-image: determining the centroid of the contour sub-image; calculating the distance between each pixel point of the contour sub-image and the centroid; counting the number of pixels corresponding to the pixel distance and the distance between the pixel point and the centroid according to the distance between each pixel point and the centroid and a plurality of other pixels corresponding to each pixel point; and the distance between the pixel point and any other corresponding pixel point is the pixel distance.
In an embodiment of the present invention, the dividing unit 602 is configured to determine a rectangular bounding box corresponding to the outline image; and dividing the contour image into a plurality of contour sub-images according to a preset division threshold value and the rectangular bounding box.
In one embodiment of the present invention, the dividing unit 602 is configured to divide the contour image into n contour sub-images in units of W/n; wherein the size of the rectangular bounding box is a × b, W = max (a, b), and n is used to characterize the partition threshold.
In one embodiment of the invention, the apparatus comprises: a normalization unit;
the normalizing unit is configured to determine a rectangular bounding box corresponding to the outline image; determining the minimum value in the distances between the pixel point corresponding to the contour image and the centroid; determining the maximum value in the distances between the pixel point corresponding to the contour image and the centroid; standardizing the distance between each pixel point and the centroid according to the rectangular bounding box, the maximum value and the minimum value;
the counting unit 603 is configured to count the number of pixels corresponding to the pixel distance and the distance between the pixel point and the centroid according to the standardized distance between each pixel point and the centroid and a plurality of other pixel points corresponding to each pixel point.
In an embodiment of the present invention, the statistical unit 603 is configured to determine whether there are other pixel points on the upper side or the lower side or the left side or the right side of the current pixel point, where the distance between the other pixel points and the centroid is equal to the distance between the current pixel point and the centroid; the distance between the current pixel point and other pixel points is the current pixel distance; if yes, adding 1 to the number of pixel points corresponding to the distance between the current pixel and the centroid; the current pixel point is any pixel point of the contour sub-image, and the current pixel distance is any one of a plurality of preset pixel distances.
As shown in fig. 7, an embodiment of the present invention provides an image processing apparatus including:
the detection unit 701 is configured to perform edge detection on an image to be identified to obtain a contour image;
a dividing unit 702 configured to divide the contour image to obtain a plurality of contour sub-images;
a statistical unit 703 configured to, for each contour sub-image: determining the centroid of the contour sub-image; calculating the distance between each pixel point of the contour subimage and the centroid; counting the number of pixel points corresponding to the pixel distance and the distance between the pixel point and the mass center according to the distance between the pixel point and the mass center and a plurality of other pixel points corresponding to the pixel point; constructing a distance autocorrelation graph according to the pixel distance, the distance between the pixel point and the centroid, and the number of pixel points corresponding to the pixel distance and the distance between the pixel point and the centroid; the distance between a pixel point and any other corresponding pixel point is the pixel distance;
the determining unit 704 is configured to compare the distance autocorrelation graphs corresponding to the image to be recognized with the distance autocorrelation graphs of the pre-acquired template image, and determine similarity between the image to be recognized and the template image.
Embodiments of the present invention provide a computer-readable storage medium having computer-readable instructions stored thereon, the computer-readable instructions being executable by a processor to implement the method of any of the above embodiments.
An embodiment of the present invention provides an image feature extraction device, including: a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform the method of any of the embodiments described above.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development, but the original code before compiling is also written in a specific Programming Language, which is called Hardware Description Language (HDL), and the HDL is not only one kind but many kinds, such as abll (Advanced boot Expression Language), AHDL (alternate hard Description Language), traffic, CUPL (computer universal Programming Language), HDCal (Java hard Description Language), lava, lola, HDL, PALASM, software, rhydl (Hardware Description Language), and vhul-Language (vhyg-Language), which is currently used in the field. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be regarded as a hardware component and the means for performing the various functions included therein may also be regarded as structures within the hardware component. Or even means for performing the functions may be conceived to be both a software module implementing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the various elements may be implemented in the same one or more pieces of software and/or hardware in the practice of the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. The use of the phrase "including a" does not exclude the presence of other, identical elements in the process, method, article, or apparatus that comprises the same element, whether or not the same element is present in all of the same element.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.