Method for enhancing optical image
Technical Field
The invention relates to a pixel point extraction method, in particular to an optical image enhancement method, and belongs to the technical field of electronic eye pattern recognition and photoelectric navigation.
Background
At present, the optical image enhancement method mainly adopts one-dimensional direction extraction, so that a pair of contrast-enhanced characteristic images can be obtained. The specific extraction method is shown in fig. 1: acquiring a corresponding pixel point pix in the one-dimensional direction of the acquired image, acquiring two adjacent points pix1 and pix2 of the pixel point pix in the one-dimensional direction, judging whether the pixel point needs to be enhanced or not through a difference value, namely, whether pix _ new is 2 pix- (pix1+ pix2) is larger than a set threshold or not, and enhancing the characteristic point if the pixel point is larger than the set threshold; the size of the threshold is related to the contrast required for the image. By the extraction method, an enhanced characteristic image can be obtained. However, because the adjacent pixels of the image sensor array have a large influence, the gray value of the acquired corresponding pixel is often very close to the gray values of several surrounding pixels, so that the purpose of contrast cannot be achieved by adopting adjacent pixel points in the one-dimensional direction, and the effect of image enhancement is not obvious.
Disclosure of Invention
The invention aims to overcome the defects in the prior art and provide the optical image enhancement method which is simple to operate, good in enhancement effect, capable of improving the enhancement efficiency and suitable for circuit implementation.
According to the technical scheme provided by the invention, the method for enhancing the optical image is characterized by comprising the following steps of: 1. inputting an image acquired in photoelectric navigation; 2. scanning the image point by point to obtain pixel values pixel (a, b) of the current pixel point, wherein a, b are respectively the abscissa and ordinate values of the current pixel point; 3. respectively obtaining pixel values of adjacent pixel points of n upper left corners and n lower left corners of a current pixel point, and respectively obtaining pixel values of adjacent pixel points of m upper right corners and m lower right corners of the current pixel point, wherein both n and m are more than or equal to 1; 4. according to the relative difference value between the current pixel point and the (2n +2m) adjacent pixel points obtained in the step 3, the relative difference value is as follows:
<math>
<mrow>
<mi>difpix</mi>
<mo>=</mo>
<mrow>
<mo>(</mo>
<mn>2</mn>
<mi>n</mi>
<mo>+</mo>
<mn>2</mn>
<mi>m</mi>
<mo>)</mo>
</mrow>
<mo>*</mo>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo>)</mo>
</mrow>
<mo>-</mo>
<mo>[</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>i</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>i</mi>
<mo>)</mo>
</mrow>
<mo>+</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>j</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>j</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>j</mi>
<mo>)</mo>
</mrow>
</mrow>
</math>
<math>
<mrow>
<mo>+</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>k</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>k</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>k</mi>
<mo>)</mo>
</mrow>
<mo>+</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>l</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>l</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>l</mi>
<mo>)</mo>
</mrow>
<mo>]</mo>
<mo>;</mo>
</mrow>
</math> wherein, <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>i</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>i</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of n adjacent pixel points at the upper left corner of the current pixel point pixel (a, b), <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>j</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>j</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>j</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of m adjacent pixel points at the bottom right corner of the current pixel point pixel (a, b), <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>k</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>k</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>k</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of m adjacent pixel points at the upper right corner of the current pixel point pixel (a, b), <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>l</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>l</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>l</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> is as followsThe sum of n adjacent pixel points at the lower left corner of the front pixel point pixel (a, b); 5. solving an absolute value | bifpixi | of the relative difference value bifpix, comparing the absolute value | bifpixi | with a set threshold value TH4, when the size of the absolute value | bifpixi | is larger than a threshold value TH4, setting a current pixel point as a characteristic pixel point, setting a pixel value of which the coordinate value of the current pixel point is (a, b) point as | bifpixi | M, and setting M as a multiple needing to be enhanced; when the absolute value | bifpix | is smaller than a threshold value TH4, setting the current pixel point as a non-characteristic pixel point and setting the pixel value of the current pixel point with the coordinate value of (a, b) point as 0; 6. after the image is scanned point by point, each point of the image is correspondingly set, and an enhanced contrast image is obtained.
When the acquired current pixel point is located at the edge of the image, the pixel values of n upper left corners, n lower left corners, m upper right corners or m lower right corners of the current pixel point are the average pixel values of the acquired image or the pixel values of the adjacent pixel points.
The invention has the advantages that: in the two-dimensional direction of the image, a plurality of pixel values which are adjacent to the opposite angles of the current pixel point are adopted for comparison, so that the situation that the gray values of the adjacent pixel points in the one-dimensional direction of the image are similar to influence the enhancement of the pixel points is avoided; the method is simple to operate, good in enhancement effect, capable of improving enhancement efficiency and suitable for circuit implementation.
Drawings
Fig. 1 is a schematic diagram of conventional optical image enhancement.
FIG. 2 is a schematic diagram of an embodiment of the present invention.
FIG. 3 is a flow chart of the extraction process according to the embodiment of the present invention.
Detailed Description
The invention is further illustrated by the following specific figures and examples.
In order to enhance the contrast of the image and highlight the characteristic information of the image, so that the matching accuracy in the mode identification process is facilitated, and the defect that the contrast of adjacent points is adopted in the one-dimensional direction of the image is avoided.
In order to enhance the contrast of an image and obtain an improved image after the contrast of the corresponding image, feature points in the image need to be extracted, and the brightness of the corresponding feature points needs to be enhanced, so as to obtain a responsive contrast image. The extraction method can be realized by the following steps:
1. inputting an image acquired in photoelectric navigation, wherein the acquired image is an image with a certain length and width, the image comprises a plurality of pixel points, the pixel value of each pixel point is different, the brightness of the corresponding point in the image needs to be enhanced, and the brightness of the background in the image is reduced, so that a contrast image with high brightness is obtained, and the matching accuracy in the pattern recognition process is facilitated;
2. scanning the image point by point to obtain pixel values pixel (a, b) of the current pixel point, wherein a, b are respectively the abscissa and ordinate values of the current pixel point;
3. respectively obtaining pixel values of adjacent pixel points of n upper left corners and n lower left corners of a current pixel point, and respectively obtaining pixel values of adjacent pixel points of m upper right corners and m lower right corners of the current pixel point, wherein both n and m are more than or equal to 1; when m is equal to n is equal to 1, adopting one pixel point of the current pixel point at the upper left corner, the lower left corner, the upper right corner and the lower right corner respectively as comparison; when m and n take other values, the brightness of the current pixel point is compared with the brightness of other adjacent pixel points in the image, so that the brightness value of the current pixel point in the image can be reflected, and the comparison accuracy of the current pixel point is improved;
d. according to the relative difference value of the current pixel point and the (2n +2m) adjacent pixel points obtained in the step 3, and according to the mode of subtracting the image pixels to calculate the contrast, the relative difference value is as follows:
<math>
<mrow>
<mi>difpix</mi>
<mo>=</mo>
<mrow>
<mo>(</mo>
<mn>2</mn>
<mi>n</mi>
<mo>+</mo>
<mn>2</mn>
<mi>m</mi>
<mo>)</mo>
</mrow>
<mo>*</mo>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo>)</mo>
</mrow>
<mo>-</mo>
<mo>[</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>i</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>i</mi>
<mo>)</mo>
</mrow>
<mo>+</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>j</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>j</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>j</mi>
<mo>)</mo>
</mrow>
</mrow>
</math>
<math>
<mrow>
<mo>+</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>k</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>k</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>k</mi>
<mo>)</mo>
</mrow>
<mo>+</mo>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>l</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>l</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>l</mi>
<mo>)</mo>
</mrow>
<mo>]</mo>
<mo>;</mo>
</mrow>
</math> wherein, <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>i</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>i</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of n adjacent pixel points at the upper left corner of the current pixel point pixel (a, b), <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>j</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>j</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>j</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of m adjacent pixel points at the bottom right corner of the current pixel point pixel (a, b), <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>k</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>m</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>-</mo>
<mi>k</mi>
<mo>,</mo>
<mi>b</mi>
<mo>+</mo>
<mi>k</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of m adjacent pixel points at the upper right corner of the current pixel point pixel (a, b), <math>
<mrow>
<munderover>
<mi>Σ</mi>
<mrow>
<mi>l</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mi>pixel</mi>
<mrow>
<mo>(</mo>
<mi>a</mi>
<mo>+</mo>
<mi>l</mi>
<mo>,</mo>
<mi>b</mi>
<mo>-</mo>
<mi>l</mi>
<mo>)</mo>
</mrow>
</mrow>
</math> the sum of n adjacent pixel points at the lower left corner of the current pixel point pixel (a, b);
5. solving an absolute value | bifpixi | of the relative difference value bifpix, comparing the absolute value | bifpixi | with a set threshold value TH4, when the size of the absolute value | bifpixi | is larger than a threshold value TH4, setting a current pixel point as a characteristic pixel point, setting a pixel value of which the coordinate value of the current pixel point is (a, b) point as | bifpixi | M, and setting M as a multiple needing to be enhanced; when the absolute value | bifpix | is smaller than a threshold value TH4, setting the current pixel point as a non-characteristic pixel point and setting the pixel value of the current pixel point with the coordinate value of (a, b) point as 0; the threshold TH4 and the enhancement factor M are set accordingly according to the requirement of image contrast. When each pixel point in the obtained image is extracted and enhanced, an enhanced contrast image can be obtained, and the matching accuracy in the pattern recognition process is improved;
6. after scanning each point in the image point by point, determining characteristic points and non-characteristic points in the image, and correspondingly setting the characteristic points and the non-characteristic points to obtain an enhanced contrast image.
When the current pixel point is located at the edge of the image, the average pixel value of the acquired image can be obtained through pre-calculation, when the pixel point has no corresponding pixel value at the upper left corner, the lower left corner, the upper right corner or the lower right corner, the corresponding pixel value at the upper left corner, the lower left corner, the upper right corner or the lower right corner is set as the average pixel value of the image, and the pixel value of the adjacent pixel point at the edge of the image can be adopted to fill the pixel value at the upper left corner, the lower left corner, the upper right corner or the lower right corner, so that the pixel point at the edge of the acquired image can also complete the contrast process, and the contrast of the image edge is improved.
Examples
As shown in fig. 2 and 3: the following describes the process of the extraction and image enhancement method of the present invention, taking n as 1 and m as 1 as an example;
1. inputting an acquired image, wherein the size of the image is TH1 multiplied by TH 2;
2. scanning the image point by point to obtain a pixel value pixel (pixRow, pixCol) of the current pixel point, wherein the pixRow and the pixCol are respectively an abscissa value and an ordinate value of the current pixel point; in order to obtain a corresponding contrast image, a corresponding row and column value needs to be initialized, so that each pixel point of the obtained image can be extracted and correspondingly processed; wherein pixCol represents a column value and pixRow represents a row value;
3. respectively acquiring pixel values of adjacent pixel points of 1 upper left corner and 1 lower left corner of a current pixel point, and respectively acquiring pixel values of adjacent pixel points of 1 upper right corner and 1 lower right corner of the current pixel point;
4. according to the relative difference value of the current pixel point and 4 adjacent pixel points obtained in the step 3, the calculation process of the relative difference value is that
difpix ═ 4 × pixel- (pixel1+ pixel2+ pixel3+ pixel4), - ((pixel4-pixel) - (pixel-pixel1) + (pixel3-pixel) - (pixel-pixel 2). The calculation idea is the most basic processing mode in image processing, namely, the contrast is obtained by subtracting image pixels. Since one pixel point is taken from the upper left corner, the lower left corner, the upper right corner and the lower right corner of the current pixel point, pixel1 is the sum of the pixel values of the upper left corner of the current pixel point, and the pixel value of pixel1 is pixel (pixRow-1, pixCol-1); pixel4 is the sum of pixel values of the lower right corner of the current pixel point, and pixel4 has a pixel value of pixel (pixRow +1, pixCol + 1); pixel3 is the sum of pixel values of the lower left corner of the current pixel point, and pixel3 has a pixel value of pixel (pixRow +1, pixCol-1); pixel2 is the sum of pixel values of the upper right corner of the current pixel point, and pixel2 has a pixel value of pixel (pixRow-1, pixCol + 1); when a plurality of upper left corner, lower left corner, upper right corner and lower right corner values of the current pixel point are taken, corresponding relative difference values can be obtained according to the values
5. Solving an absolute value | diffpix | of the relative difference value diffpix, comparing the absolute value | diffpix | with a set threshold value TH4, when the size of the absolute value | diffpix | is larger than a threshold value TH4, determining that the current pixel point is a feature point of an image, and setting a pixel value of a (pixRow, pixCol) point as a current pixel point coordinate value | diffpix | M, wherein M is a multiple needing to be enhanced; when the absolute value | bifpix | is smaller than a threshold value TH4, setting the pixel value of a point with a coordinate value of (pixRow, pixCol) as 0, wherein the current pixel point is not a feature point of the image; sequentially comparing corresponding pixel points of images with the size of TH1 multiplied by TH2 according to the value sequence of corresponding rows and columns, searching corresponding characteristic points and non-characteristic points, and correspondingly processing the pixel values of the characteristic points and the non-characteristic points to obtain a required comparison image, wherein the comparison image highlights the characteristic information of the images;
6. after scanning each point in the image point by point, determining characteristic points and non-characteristic points in the image, and correspondingly setting the characteristic points and the non-characteristic points to obtain an enhanced contrast image.
According to the method, in the two-dimensional direction of the image, the pixel values of a plurality of opposite angles adjacent to the current pixel point are compared, so that the influence on the enhancement of the pixel point caused by the proximity of the gray values of the adjacent pixel points in the one-dimensional direction of the image is avoided; the method has simple operation, good enhancement effect, improved enhancement efficiency, and suitability for circuit realization