[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN114359583A - Gradient histogram angle rapid calculation method - Google Patents

Gradient histogram angle rapid calculation method Download PDF

Info

Publication number
CN114359583A
CN114359583A CN202011058419.4A CN202011058419A CN114359583A CN 114359583 A CN114359583 A CN 114359583A CN 202011058419 A CN202011058419 A CN 202011058419A CN 114359583 A CN114359583 A CN 114359583A
Authority
CN
China
Prior art keywords
ori
image
gradient
angle
tan
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011058419.4A
Other languages
Chinese (zh)
Inventor
余慧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ingenic Semiconductor Co Ltd
Original Assignee
Beijing Ingenic Semiconductor Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ingenic Semiconductor Co Ltd filed Critical Beijing Ingenic Semiconductor Co Ltd
Priority to CN202011058419.4A priority Critical patent/CN114359583A/en
Publication of CN114359583A publication Critical patent/CN114359583A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)

Abstract

The invention adopts a simple and convenient way to conveniently and rapidly calculate the gradient direction, and particularly provides a method for rapidly calculating the gradient histogram angle, which comprises the following steps: s1, if the direction of the image is defined as the included angle a between gx and gy, the original gradient direction calculation method is: a ═ arctan (gy/gx), i.e.: tan a ═ gy/gx, where gx and gy are the gradients of the image at the (x, y) point in the x-direction and y-direction, respectively; s2, assuming that N directions are divided from 0 ° to 180 °, not divided into positive and negative, and an unsigned gradient, each N degree is a direction where [0 ° - (N/2) ° ], ((180-N/2) ° -180 ° ] is ori _1, where N is a positive integer greater than 1, the angle N of each direction is 180/N, S3, since the tan value of each boundary angle is known, it is directly determined by the correspondence that the direction ori is the several direction from the 1 st direction to the N th direction from the value of tan a, dy/dx.

Description

Gradient histogram angle rapid calculation method
Technical Field
The invention relates to the technical field of image processing, in particular to a method for rapidly calculating an angle of a gradient histogram.
Background
In the prior art, the method of calculating the image gradient is generally performed as follows:
1. calculating the gradient direction and amplitude of the image
For image pixel point (i, j): the gradient Hx (i, j) of the X-direction and the gradient Hy (i, j) of the Y-direction
Hx(i,j)=I(i+1,j)-I(i,j)
Hy(i,j)=I(i,j)-I(i,j+1)
The image can be convolved using the gradient operator sobel, Laplacian.
The gradient amplitude M (x, y) and the gradient direction θ (x, y) can thus be determined:
Figure BDA0002711491590000011
θ(x,y)=arctan(Hy/Hx)
2. calculating bin value
The gradient direction θ is [0,180], which is divided into n bins. For example, in OpenCV, n is 9, i.e., a circle is divided into 9 parts, each part interval corresponds to a bin value, e.g., 0 ≦ θ <40 corresponds to a bin 0, and when a certain gradient direction is in the range of [0,40), it corresponds to a bin 0 plus 1, and the magnitude is the weight when calculating the number of bins, and then in the above example, if M is 2, then a bin 0 plus 1 is 2. This results in a count for each bin.
The angles are 0-180 degrees and not 0-360 degrees, this is called "unsigned" gradients because a gradient and its negative are represented by the same number, i.e., the arrow of a gradient and the direction of the arrow after it has been rotated 180 degrees are considered the same, and it has been found in experiments that unsigned gradients perform better than signed gradients (0-360 degrees) in human target detection tasks.
3. Counting bin numbers to form HOG descriptor
The statistics are performed in a window area of an image, and the area size and the sliding mode are determined using parameters such as cellSize, blockSize, blockStride, and winSize.
In each Cell, gradient direction statistics is independently performed, so that a histogram with the gradient direction as a horizontal axis shows that the gradient direction can be 0-180 degrees or 0-360 degrees, but the dalal experiment shows that a better result can be obtained for detecting the direction range of 0-180 degrees, namely the direction range with a positive or negative neglected degree. This gradient profile is then divided equally into 9 orientation bins, each of which corresponds to a square column, as shown in FIG. 2.
The image gradient direction is involved in calculating the HOG feature of the image, arctan is needed to calculate the gradient direction value in practical programming from the viewpoint of the gradient direction definition of the image, and the step is in a large cycle, so that the calculation is slow and complex.
Furthermore, technical terms commonly used in the art include:
histogram of organized grids, abbreviated as HOG, is a feature commonly used in the field of computer vision and pattern recognition to describe local textures of images. It constructs features by calculating and counting the histogram of gradient direction of local area of image. The common method is that Hog characteristics are combined with SVM to carry out image recognition and classification.
2. Image gradient values and directions:
in calculus, the basic definition of the first order differential of a one-dimensional function is such that:
df/dx=lim(f(x+∈)-f(x))/∈(∈→0)。
disclosure of Invention
In order to solve the problems in the prior art, the present invention aims to: the gradient direction is conveniently and rapidly calculated in a simple and convenient mode.
Specifically, the invention provides a method for rapidly calculating an angle of a gradient histogram, which comprises the following steps:
s1, if the direction of the image is defined as the included angle a between gx and gy, the original gradient direction calculation method is:
a ═ arctan (gy/gx), i.e.: tan a ═ gy/gx, where gx and gy are the gradients of the image at the (x, y) point in the x-direction and y-direction, respectively;
s2, assuming that N directions are divided by 0 ° to 180 °, plus and minus, unsigned gradients, one direction per N degrees, where [0 ° — (N/2) ° ], ((180-N/2) ° -180 ° ] is ori _1, where N is a positive integer greater than 1, the angle N for each direction is 180/N, i.e.:
Figure BDA0002711491590000031
at S3, since the tan value of each boundary angle is known, it is directly determined from the tan a, that is, the value of dy/dx that the direction ori is the several direction from the 1 st direction to the nth direction by the correspondence relationship.
In the method, the degree from zero to 180 degrees is divided into N directions, N is determined according to the actual situation, the calculation mode is unchanged, and the tan value is correspondingly changed according to the actual division.
The step S2 further includes: let N be 9 directions, not divided into positive and negative, unsigned gradient, and each N be 20 degrees, which is one direction, where 0 ° -10 °, 170 ° -180 ° is ori _1, that is:
angle A Direction ori
(0°,10°),(170°,180°) ori=1
(10°,30°) ori=2
(30°,50°) ori=3
(50°,70°) ori=4
(70°,90°) ori=5
(90°,110°) ori=6
(110°,130°) ori=7
(130°,150°) ori=8
(150°,170°) ori=9
In step S3, it is directly determined from the relation of correspondence that the direction ori is the fifth direction by dy/dx, that is:
tanA direction ori
dx=0 ori=5
(-0.1763,0.1763) ori=1
(0.1763,0.5774) ori=2
(0.5774,1.1918) ori=3
(1.1918,2.7475) ori=4
(2.7475,) ori=5
(,-2.7475) ori=6
(-2.7475,-1.1918) ori=7
(-1.1918,-0.5774) ori=8
(-0.5774,-0.1763) ori=9
Here, ori is 5, which is actually calculated, and when dx is 0, dy/dx- > ∞, arctan (∞) — 90, that is, the corresponding angle is 90 degrees, so ori is 5.
(2.7475,) denotes > 2.7475;
(, -2.7475) represents < -2.7475;
in the method, the image is a two-dimensional function f (x, y), and the differential is a partial differential; therefore, there are:
Figure BDA0002711491590000052
Figure BDA0002711491590000053
because the image is a discrete two-dimensional function, the epsilon cannot be infinitely small, the image is discrete according to pixels, and the minimum epsilon is 1 pixel; the above image differentiation therefore becomes again of the form in which e is 1:
Figure BDA0002711491590000054
Figure BDA0002711491590000055
these are the gradients of the image in the x-direction and y-direction, respectively, at the (x, y) point, which, as seen from the above expression, corresponds to the difference between 2 adjacent pixels.
The gradients in the x-direction and the y-direction may be represented together by the following equation:
Figure BDA0002711491590000051
the operation of approximating the square and square root with absolute values reduces the amount of computation:
M(x,y)=|gx|+|gy|。
the method can further convert the division operation comparison of dy/dx into multiplication operation comparison or into integer calculation on the basis of the multiplication operation comparison.
In summary, the method of the present application can achieve the following advantages: the image gradient direction is involved in the calculation of the HOG characteristics of the image, and the calculation speed can be increased and the calculation steps can be simplified by using the method in the actual programming from the definition of the image gradient direction.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention.
FIG. 1 is a schematic block flow diagram of the method of the present invention.
Fig. 2 is a schematic diagram of a histogram with gradient direction as horizontal axis involved in the method of the present invention.
FIG. 3 is a schematic diagram of the method of the present invention in which the gradient direction is divided into 9 directions, wherein the gradient is not divided into positive and negative, but is unsigned.
Detailed Description
In order that the technical contents and advantages of the present invention can be more clearly understood, the present invention will now be described in further detail with reference to the accompanying drawings.
In calculating the image gradient values and directions: in calculus, if the image is a two-dimensional function f (x, y), the derivative is, of course, partial. Therefore, there are:
Figure BDA0002711491590000062
Figure BDA0002711491590000063
because the image is a discrete two-dimensional function, e cannot be infinitely small, the image is discrete by pixel, and the smallest e is 1 pixel. The above image differentiation therefore becomes again of the form (∈ ═ 1):
Figure BDA0002711491590000064
Figure BDA0002711491590000065
these are the gradients of the image in the x-direction and y-direction, respectively, at the (x, y) point, which, as can be seen from the above expression, corresponds to the difference between 2 adjacent pixels.
The gradients in the x and y directions can be represented together by the following equation:
Figure BDA0002711491590000061
here, the square is also the square, and the square is also the open, the calculation amount is relatively large, so the operation of approximating the square and the square root by the absolute value is generally used to reduce the calculation amount:
M(x,y)=|gx|+|gy|
the direction of the image is defined as the angle A between gx and gy
tanA=gy/gx
The following can be obtained:
A=arctan(gy/gx)。
therefore, as shown in fig. 1, the present application relates to a method for fast calculating gradient histogram angle, comprising the following steps:
s1, if the direction of the image is defined as the included angle a between gx and gy, the original gradient direction calculation method is:
a ═ arctan (gy/gx), i.e.: tan a ═ gy/gx, where gx and gy are the gradients of the image at the (x, y) point in the x-direction and y-direction, respectively;
s2, assuming that N directions are divided by 0 ° to 180 °, plus and minus, unsigned gradients, one direction per N degrees, where [0 ° — (N/2) ° ], ((180-N/2) ° -180 ° ] is ori _1, where N is a positive integer greater than 1, the angle N for each direction is 180/N, i.e.:
Figure BDA0002711491590000071
at S3, since the tan value of each boundary angle is known, it is directly determined from the tan a, that is, the value of dy/dx that the direction ori is the several direction from the 1 st direction to the nth direction by the correspondence relationship.
Specifically, the following is further described:
original gradient direction calculation mode:
A=arctan(dy/dx)
namely:
tanA=dy/dx
it is assumed that there are 9 directions (not positive and negative, unsigned gradients) as shown in fig. 3.
Every 20 degrees is a direction, specifically 0-10, 170-180 is ori _1, i.e.:
A~(0°,10°),(170°,180°):ori=1
A~(10°,30°):ori=2
A~(30°,50°):ori=3
A~(50°,70°):ori=4
A~(70°,90°):ori=5
A~(90°,110°):ori=6
A~(110°,130°):ori=7
A~(130°,150°):ori=8
A~(150°,170°):ori=9
however, the tan value of each boundary angle is known, so that ori can be directly determined as the direction from tanA, dy/dx, that is:
dx=0:ori=5
dy/dx~(-0.1763,0.1763):ori=1
dy/dx~(0.1763,0.5774):ori=2
dy/dx~(0.5774,1.1918):ori=3
dy/dx~(1.1918,2.7475):ori=4
dy/dx~(2.7475,):ori=5
dy/dx~(,-2.7475):ori=6
dy/dx~(-2.7475,-1.1918):ori=7
dy/dx~(-1.1918,-0.5774):ori=8
dy/dx~(-0.5774,-0.1763):ori=9
in actual programming, the division comparison of dy/dx can be further converted into multiplication comparison, or converted into integer calculation on the basis, so that the operation efficiency is further improved.
In addition, it is explicitly stated in the present application that 180 degrees is divided into N directions, so that the user can determine N according to actual conditions, the above calculation method is not changed, and the tan value may vary according to actual division.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes may be made to the embodiment of the present invention by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (7)

1. A method for fast computing gradient histogram angles is characterized by comprising the following steps:
s1, if the direction of the image is defined as the included angle a between gx and gy, the original gradient direction calculation method is:
a ═ arctan (gy/gx), i.e.: tan a ═ gy/gx, where gx and gy are the gradients of the image at the (x, y) point in the x-direction and y-direction, respectively;
s2, assuming that N directions are divided by 0 ° to 180 °, plus and minus, unsigned gradients, one direction per N degrees, where [0 ° — (N/2) ° ], ((180-N/2) ° -180 ° ] is ori _1, where N is a positive integer greater than 1, the angle per direction is N180/N, i.e.:
Figure FDA0002711491580000011
at S3, since the tan value of each boundary angle is known, it is directly determined from the tan a, that is, the value of dy/dx that the direction ori is the several direction from the 1 st direction to the nth direction by the correspondence relationship.
2. The method as claimed in claim 1, wherein the method divides the degree from zero to 180 degrees into N directions, determines N according to the actual situation, the calculation is not changed, and the tan value varies according to the actual division.
3. The method for fast computing gradient histogram angle according to claim 1, wherein the step S2 further comprises: let N be 9 directions, not divided into positive and negative, unsigned gradient, and each N be 20 degrees, which is one direction, where 0 ° -10 °, 170 ° -180 ° is ori _1, that is:
angle A Direction ori (0°,10°),(170°,180°) ori=1 (10°,30°) ori=2 (30°,50°) ori=3 (50°,70°) ori=4 (70°,90°) ori=5 (90°,110°) ori=6 (110°,130°) ori=7 (130°,150°) ori=8 (150°,170°) ori=9
4. The method as claimed in claim 3, wherein the step S3 directly determines that the direction ori is the fifth direction from tan A, dy/dx according to the corresponding relationship, that is:
Figure FDA0002711491580000021
Figure FDA0002711491580000031
5. a method for fast computation of gradient histogram angles according to claim 3, characterized in that in said method the image is a two-dimensional function f (x, y) whose differential is of course partial differential; therefore, there are:
Figure FDA0002711491580000032
Figure FDA0002711491580000033
because the image is a discrete two-dimensional function, the epsilon cannot be infinitely small, the image is discrete according to pixels, and the minimum epsilon is 1 pixel; the above image differentiation therefore becomes again of the form in which e is 1:
Figure FDA0002711491580000034
Figure FDA0002711491580000035
these are the gradients of the image in the x-direction and y-direction, respectively, at the (x, y) point, which, as seen from the above expression, corresponds to the difference between 2 adjacent pixels.
6. A method for fast computation of gradient histogram angles as claimed in claim 5, wherein the gradients in x-direction and y-direction are represented together by the following sub-equations:
Figure FDA0002711491580000036
the operation of approximating the square and square root with absolute values reduces the amount of computation:
M(x,y)=|gx|+|gy|。
7. the method as claimed in claim 1, wherein the method further converts dy/dx division comparison into multiplication comparison, or further converts the division comparison into integer calculation based on the multiplication comparison.
CN202011058419.4A 2020-09-30 2020-09-30 Gradient histogram angle rapid calculation method Pending CN114359583A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011058419.4A CN114359583A (en) 2020-09-30 2020-09-30 Gradient histogram angle rapid calculation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011058419.4A CN114359583A (en) 2020-09-30 2020-09-30 Gradient histogram angle rapid calculation method

Publications (1)

Publication Number Publication Date
CN114359583A true CN114359583A (en) 2022-04-15

Family

ID=81089836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011058419.4A Pending CN114359583A (en) 2020-09-30 2020-09-30 Gradient histogram angle rapid calculation method

Country Status (1)

Country Link
CN (1) CN114359583A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101770583A (en) * 2010-01-15 2010-07-07 华中科技大学 Template matching method based on global features of scene
CN102446358A (en) * 2012-01-17 2012-05-09 南京航空航天大学 Multi-modal medical image registration method based on edge features and CS information
US20140072217A1 (en) * 2012-09-11 2014-03-13 Sharp Laboratories Of America, Inc. Template matching with histogram of gradient orientations
CN104036282A (en) * 2014-04-01 2014-09-10 西北工业大学 Triangular sailboard support frame identification method applicable to space non-cooperative target
CN108052971A (en) * 2017-12-11 2018-05-18 奕响(大连)科技有限公司 One kind is based on the similar determination method of the improved pictures of HOG
CN108090470A (en) * 2018-01-10 2018-05-29 浙江大华技术股份有限公司 A kind of face alignment method and device
CN108182442A (en) * 2017-12-29 2018-06-19 惠州华阳通用电子有限公司 A kind of image characteristic extracting method
CN108830279A (en) * 2018-04-03 2018-11-16 南昌奇眸科技有限公司 A kind of image characteristics extraction and matching process
CN108846843A (en) * 2018-04-03 2018-11-20 南昌奇眸科技有限公司 A kind of image characteristic extracting method
CN109478242A (en) * 2014-11-28 2019-03-15 快图有限公司 Method for generating histograms of oriented gradients

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101770583A (en) * 2010-01-15 2010-07-07 华中科技大学 Template matching method based on global features of scene
CN102446358A (en) * 2012-01-17 2012-05-09 南京航空航天大学 Multi-modal medical image registration method based on edge features and CS information
US20140072217A1 (en) * 2012-09-11 2014-03-13 Sharp Laboratories Of America, Inc. Template matching with histogram of gradient orientations
CN104036282A (en) * 2014-04-01 2014-09-10 西北工业大学 Triangular sailboard support frame identification method applicable to space non-cooperative target
CN109478242A (en) * 2014-11-28 2019-03-15 快图有限公司 Method for generating histograms of oriented gradients
CN108052971A (en) * 2017-12-11 2018-05-18 奕响(大连)科技有限公司 One kind is based on the similar determination method of the improved pictures of HOG
CN108182442A (en) * 2017-12-29 2018-06-19 惠州华阳通用电子有限公司 A kind of image characteristic extracting method
CN108090470A (en) * 2018-01-10 2018-05-29 浙江大华技术股份有限公司 A kind of face alignment method and device
CN108830279A (en) * 2018-04-03 2018-11-16 南昌奇眸科技有限公司 A kind of image characteristics extraction and matching process
CN108846843A (en) * 2018-04-03 2018-11-20 南昌奇眸科技有限公司 A kind of image characteristic extracting method

Similar Documents

Publication Publication Date Title
Gallego et al. Focus is all you need: Loss functions for event-based vision
Paglieroni Distance transforms: Properties and machine vision applications
Chung et al. A non-parametric blur measure based on edge analysis for image processing applications
Hofmann et al. Background segmentation with feedback: The pixel-based adaptive segmenter
US9122954B2 (en) Performing a histogram using an array of addressable registers
US20150161480A1 (en) Method and system for matching an image using normalized feature vectors
Nair et al. Robust focus ranging
CN114612978A (en) System and method for providing an image classifier
McLaughlin Randomized Hough transform: better ellipse detection
CN110598788A (en) Target detection method and device, electronic equipment and storage medium
CN107545251A (en) Face quality discrimination and the method and device of picture enhancing
CN104978738A (en) Method of detection of points of interest in digital image
CN111105452A (en) High-low resolution fusion stereo matching method based on binocular vision
CN101315664A (en) Text image preprocessing method for character recognition
CN104537381A (en) Blurred image identification method based on blurred invariant feature
CN113743147B (en) Anti-fuzzy two-dimensional code image based on fuzzy imaging mechanism and blind restoration method thereof
CN114359583A (en) Gradient histogram angle rapid calculation method
Yang et al. Contrast limited adaptive histogram equalization for an advanced stereo visual slam system
CN112785512A (en) Optimization algorithm for Gaussian blur image processing
CN104809705A (en) Image denoising method and system based on threshold value block matching
US6693669B1 (en) Method for reducing image blurring
CN111543045B (en) Real-time brightness optimization and contrast optimization of images
CN108765305A (en) A kind of defocus QR code method for blindly restoring image
CN113724129B (en) Image blurring method, storage medium and terminal equipment
CN117690007B (en) High-frequency workpiece image recognition method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination