CN110610451B - Image gradient calculation device - Google Patents

Image gradient calculation device Download PDF

Info

Publication number
CN110610451B
CN110610451B CN201910739819.2A CN201910739819A CN110610451B CN 110610451 B CN110610451 B CN 110610451B CN 201910739819 A CN201910739819 A CN 201910739819A CN 110610451 B CN110610451 B CN 110610451B
Authority
CN
China
Prior art keywords
convolution
value
numerical value
gradient
module
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.)
Active
Application number
CN201910739819.2A
Other languages
Chinese (zh)
Other versions
CN110610451A (en
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.)
Shenzhen Intellifusion Technologies Co Ltd
Original Assignee
Shenzhen Intellifusion Technologies 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 Shenzhen Intellifusion Technologies Co Ltd filed Critical Shenzhen Intellifusion Technologies Co Ltd
Priority to CN201910739819.2A priority Critical patent/CN110610451B/en
Publication of CN110610451A publication Critical patent/CN110610451A/en
Application granted granted Critical
Publication of CN110610451B publication Critical patent/CN110610451B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/50Adding; Subtracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/52Multiplying; Dividing
    • G06F7/523Multiplying only
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/544Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices for evaluating functions by calculation
    • G06F7/552Powers or roots, e.g. Pythagorean sums
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The application discloses image gradient calculation device, the device includes image data input buffer unit, template convolution calculating unit, gradient amplitude calculating unit, gradient angle calculating unit and gradient data output buffer unit, template convolution calculating unit is connected with image data input buffer unit, gradient amplitude calculating unit and gradient angle calculating unit respectively, gradient data output buffer unit is connected with gradient amplitude calculating unit and gradient angle calculating unit respectively, adopt this application embodiment can improve image gradient's computational rate.

Description

Image gradient calculation device
Technical Field
The application relates to the technical field of electronics, in particular to an image gradient calculating device.
Background
Image gradient refers to the change in gray level of each pixel in the image in its neighborhood. Image gradient calculation is an important intermediate step of algorithms such as image edge extraction and target tracking, and a small-area template is usually adopted to perform convolution calculation to solve an image gradient so as to obtain two important physical quantities in the image gradient: gradient magnitude and gradient angle. The calculation method is realized by software (namely, a general processor ARM or a digital signal processor DSP is realized by program instructions), and the calculation speed is slow.
Disclosure of Invention
The embodiment of the application provides an image gradient calculating device, which is used for improving the calculating speed of image gradients.
In a first aspect, an embodiment of the present application provides an image gradient calculation apparatus, where the apparatus includes an image data input buffer unit, a template convolution calculation unit, a gradient amplitude calculation unit, a gradient angle calculation unit, and a gradient data output buffer unit, the template convolution calculation unit is connected to the image data input buffer unit, the gradient amplitude calculation unit, and the gradient angle calculation unit, respectively, and the gradient data output buffer unit is connected to the gradient amplitude calculation unit and the gradient angle calculation unit, respectively;
the image data input cache unit is used for caching relevant information of M x N pixel points included in an input image, wherein M and N are integers larger than 1;
the template convolution calculating unit is used for reading relevant information required for calculating the convolution of the target pixel point from the image data input cache unit and calculating the convolution of the target pixel point in the process of caching the relevant information of the pixel point by the image data input cache unit;
the gradient amplitude calculation unit is used for acquiring the convolution of the target pixel point and calculating the gradient amplitude of the target pixel point;
the gradient angle calculation unit is used for acquiring the convolution of the target pixel point and calculating the gradient angle of the target pixel point;
and the gradient data output caching unit is used for caching the gradient amplitude of the target pixel point and the gradient angle of the target pixel point.
Preferably, the image data input buffer unit includes an image row data buffer module, an image data selection module and an image column data register module, the image row data buffer module includes K first buffer areas, K is an integer greater than 1, the image row data buffer module is connected with the image data selection module, and the image data selection module is connected with the image column data register module;
the image line data caching module is configured to cache relevant information of K × N pixels in the relevant information of M × N pixels to the K first cache regions, each first cache region is configured to cache relevant information of N pixels, N pixels corresponding to the relevant information of N pixels cached in each first cache region are adjacent to each other, and M is greater than K;
the image line data caching module is further configured to delete the used related information of the pixel points of the first cache region after the related information of the pixel points of the first cache region is used up, and cache the related information of the pixel points which are not cached to the K first cache regions into the first cache region;
the image data selection module is used for selecting relevant information required for calculating convolution of target pixel points from the relevant information of the pixel points cached to the K first cache regions;
and the image column data register module is used for registering the related information required by the convolution of the calculation target pixel point.
Preferably, the template convolution calculation unit includes an X-direction template convolution calculation module and a Y-direction template convolution calculation module, the X-direction template convolution calculation module includes at least a plurality of first multipliers and first adders, and the Y-direction template convolution calculation module includes at least a plurality of second multipliers and second adders;
the at least a plurality of first multipliers are used for calculating a first product of matrix elements in the convolution template in the X direction and the related information required by the convolution of the calculation target pixel points;
the at least a plurality of second multipliers are used for calculating second products of matrix elements in the convolution template in the Y direction and the related information required by the convolution of the calculation target pixel points;
the first adder is used for calculating the sum of the first products to obtain X-direction convolution;
and the second adder is used for calculating the sum of the second products so as to obtain the convolution in the Y direction.
Preferably, the gradient magnitude calculation unit comprises a square sum calculation module and a square root calculation module, and the square sum calculation module is connected with the square root calculation module;
the square sum calculation module is configured to calculate a first numerical value, where the first numerical value is a sum of a square of the X-direction convolution and a square of the Y-direction convolution;
and the square root calculating module is used for calculating a second numerical value, wherein the second numerical value is the square root of the first numerical value, and the second numerical value is the gradient amplitude of the target pixel point.
Preferably, the square sum computation module comprises at least two third multipliers and a third adder;
one of the at least two third multipliers for calculating a square of the X-direction convolution;
another one of the at least two third multipliers for calculating a square of the Y-direction convolution;
the third adder is configured to calculate a square of the X-direction convolution and a square of the Y-direction convolution to obtain a first numerical value.
Preferably, the square root computation module is configured to convert a square root computation into a plurality of first iterative computations, where the first iterative computations include addition computations and multiplication computations, and the square root computation module includes a first register, at least two fourth multipliers, and a first subtractor;
the first register is used for storing a third numerical value, and the initial value of the third numerical value is the first numerical value;
one of the at least two fourth multipliers is configured to square the third value to obtain a fourth value;
the first subtractor is used for calculating the difference between a first constant and the fourth value to obtain a fifth value, wherein the first constant is a preset constant;
and the other one of the at least two fourth multipliers is used for calculating the sum of the third value and the fifth value to obtain a sixth value, and the sixth value is a new third value.
Preferably, the gradient angle calculation unit is configured to convert the gradient angle calculation into a plurality of second iterative calculations, the second iterative calculations including addition calculations and/or subtraction calculations, and the gradient angle calculation unit includes at least three second registers, at least three fourth adders, and a second subtractor;
a second register i, configured to store a seventh value, where an initial value of the seventh value is the X-direction convolution; a second register j, configured to store an eighth value, where an initial value of the eighth value is the Y-direction convolution; the second register k is used for storing a ninth numerical value, and the initial value of the ninth numerical value is a preset numerical value; the second register i, the second register j and the second register k are all one of the at least three second registers;
an adder i, configured to calculate a sum of the seventh numerical value and a tenth numerical value to obtain an eleventh numerical value, where the eleventh numerical value is a new seventh numerical value, and the tenth numerical value is a numerical value obtained after shifting the third numerical value;
an adder j, configured to calculate a sum of the eighth numerical value and a twelfth numerical value to obtain a thirteenth numerical value, where the thirteenth numerical value is a new eighth numerical value, and the twelfth numerical value is a numerical value obtained by shifting the seventh numerical value;
an adder k, configured to calculate a sum of the ninth value and a fourteenth value to obtain a fifteenth value, where the fifteenth value is a new ninth value, the fourteenth value is an inverse trigonometric function value stored in a lookup table, and the adder i, the adder j, and the adder k are all one of the at least three fourth adders; or, the second subtractor is configured to calculate a difference between the ninth value and the fourteenth value to obtain a sixteenth value, where the sixteenth value is a new ninth value, and the gradient angle of the target pixel is a ninth value obtained through the second iterative computations for the multiple times.
Preferably, the gradient data output buffer unit includes K second buffer areas, each second buffer area is configured to buffer gradient amplitudes and gradient angles of N pixel points, N pixel points corresponding to the gradient amplitudes and gradient angles of the N pixel points buffered in each second buffer area are adjacent to each other, and the target pixel point includes the N pixel points.
It can be seen that, in the embodiment of the present application, the image gradient calculation apparatus includes an image data input buffer unit, a template convolution calculation unit, a gradient amplitude calculation unit, a gradient angle calculation unit, and a gradient data output buffer unit, where the five units are all computer hardware, and the convolution, gradient amplitude, and gradient angle of each pixel point are calculated by the relevant computer hardware respectively.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic block diagram of an image gradient calculation apparatus provided in an embodiment of the present application;
fig. 2 is a schematic structural diagram of an image data input buffer unit according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a template convolution calculating unit according to an embodiment of the present application;
FIG. 4 is a block diagram of a square sum computation module according to an embodiment of the present disclosure;
FIG. 5 is a block diagram of a square root computation module according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a gradient magnitude calculation unit according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a gradient angle calculating unit provided in an embodiment of the present application;
fig. 8 is a schematic structural diagram of a gradient data output buffer unit according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of an image gradient calculation apparatus according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The following are detailed descriptions.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
Hereinafter, some terms in the present application are explained so as to be easily understood by those skilled in the art.
Referring to fig. 1, fig. 1 is a schematic block diagram of an image gradient calculating apparatus according to an embodiment of the present disclosure. The device comprises an image data input buffer unit 100, a template convolution calculating unit 200, a gradient amplitude calculating unit 300, a gradient angle calculating unit 400 and a gradient data output buffer unit 500, wherein the template convolution calculating unit 200 is respectively connected with the image data input buffer unit 100, the gradient amplitude calculating unit 300 and the gradient angle calculating unit 400, and the gradient data output buffer unit 500 is respectively connected with the gradient amplitude calculating unit 300 and the gradient angle calculating unit 400;
the image data input buffer unit 100 is configured to buffer relevant information of M × N pixel points included in an input image, where M and N are integers greater than 1;
the template convolution calculating unit 200 is configured to, in a process that the image data input buffer unit buffers the relevant information of the pixel, read the relevant information required for calculating the convolution of the target pixel from the image data input buffer unit 100, and calculate the convolution of the target pixel;
the gradient amplitude calculation unit 300 is configured to obtain a convolution of the target pixel point, and calculate a gradient amplitude of the target pixel point;
the gradient angle calculation unit 400 is configured to obtain the convolution of the target pixel and calculate a gradient angle of the target pixel;
the gradient data output buffer unit 500 is configured to buffer the gradient amplitude of the target pixel and the gradient angle of the target pixel.
The related information comprises the coordinates of the pixel points and the pixel values of the pixel points.
The image gradient calculating device calculates the gradient amplitude and the gradient angle sequence of the M pixel points according to the ascending sequence of the horizontal axis of the pixel point coordinate, or according to the ascending sequence of the vertical axis of the pixel point coordinate, or according to the descending sequence of the horizontal axis of the pixel point coordinate, or according to the descending sequence of the vertical axis of the pixel point coordinate; one pixel point may be calculated each time, or a plurality of pixel points may be calculated each time, which is not limited herein.
In an implementation manner of the present application, the apparatus further includes an image data analyzing unit and an image data acquiring unit, wherein:
the image data analysis unit is configured to analyze the input image to obtain a pixel point matrix, where the number of rows of the pixel point matrix is M, the number of columns of the pixel points is N, and the size and the position of each matrix element in the pixel point matrix respectively represent a pixel value and a coordinate of each pixel point.
The image data obtaining unit is used for obtaining the relevant information of M × N pixel points included in the input image.
For example, a pixel matrix obtained by analyzing an input image is F, and the specific form of the pixel matrix is as follows:
Figure BDA0002163559990000071
the pixel matrix F has M rows and N columns. For another example, F (x, y) represents the pixel value of the pixel point with coordinates (x, y) in the pixel point matrix F, and the pixel point is located in the x-th row and y-th column in the pixel point matrix.
The obtaining of the relevant information of the M × N pixels included in the input image may be sequentially obtaining the relevant information of the M × N pixels included in the input image one by one according to a preset sequence, may also be sequentially obtaining the relevant information of the M × N pixels included in the input image line by line according to the preset sequence, and may also be wholly obtaining the relevant information of the M × N pixels included in the input image together, which is not limited herein.
Wherein the preset sequence comprises at least one of: the horizontal axes of the coordinates are in a sequentially increasing order, the vertical axes of the coordinates are in a sequentially increasing order, the horizontal axes of the coordinates are in a sequentially decreasing order, and the vertical axes of the coordinates are in a sequentially decreasing order.
For example, assuming that the preset sequence is a sequence in which a horizontal axis and a vertical axis of a coordinate are sequentially increased, the related information of M × N pixels included in the input image is sequentially acquired one by one according to the preset sequence: the method comprises the steps of obtaining f (0, 0) of a first row, then obtaining f (0, 1) of the first row, then obtaining f (0, N-1) of the first row, then obtaining f (1, 0) of a second row, obtaining f (1, 1) of the second row, and till obtaining the relevant information of all pixel points.
It can be seen that, in the embodiment of the present application, the image gradient calculation apparatus includes an image data input buffer unit, a template convolution calculation unit, a gradient amplitude calculation unit, a gradient angle calculation unit, and a gradient data output buffer unit, where the five units are all computer hardware, and the convolution, gradient amplitude, and gradient angle of each pixel point are calculated by the relevant computer hardware respectively.
Referring to fig. 2, fig. 2 is a schematic structural diagram of an image data input buffer unit 100 according to an embodiment of the present disclosure. The image data input buffer unit 100 includes an image row data buffer module 110, an image data selection module 120 and an image column data register module 130, where the image row data buffer module 110 includes K first buffer areas, where K is an integer greater than 1, the image row data buffer module 110 is connected to the image data selection module 120, and the image data selection module 120 is connected to the image column data register module 130;
the image line data caching module 110 is configured to cache relevant information of K × N pixels in the relevant information of the M × N pixels in the K first cache regions, where each first cache region is configured to cache relevant information of N pixels, N pixels corresponding to the relevant information of the N pixels cached in each first cache region are adjacent to each other, and M is greater than K;
the image line data caching module 110 is further configured to delete the used related information of the pixel point of the first cache region after the related information of the pixel point of the first cache region is used up, and cache the related information of the pixel point which is not cached in the K first cache regions into the first cache region;
the image data selection module 120 is configured to select, from the relevant information of the pixels cached to the K first cache regions, relevant information required for calculating convolution of a target pixel; the image column data register module 130 is configured to register related information required for convolution of the calculation target pixel point.
The image column data register module allows the size of the buffered related information to be consistent with the size of the convolution template. For example, if the size of the convolution template is 3 × 3, the number of pieces of related information allowed to be buffered by the image column data register module is also 3 × 3.
For example, if M is 5, n is 5, k is 3, the number of pieces of related information included in the pixels is 5 × 5, and the image line data caching module is configured to cache the related information (f (0, 0), f (0, 1), f (0, 2), f (0, 3), and f (0, 4)) of the first row of 5 pixels in the first cache region a, cache the related information (f (1, 0), f (1, 1), f (1, 2), f (1, 3), and f (1, 4)) of the second row of 5 pixels in the first cache region b, and cache the related information (f (2, 0), f (2, 1), f (2, 2), f (2, 3), and f (2, 4)) of the third row of 5 pixels in the first cache region c; after the related information (f (0, 0), f (0, 1), f (0, 2), f (0, 3) and f (0, 4)) of the pixel point of the first cache region a is used up, the related information (f (0, 0), f (0, 1), f (0, 2), f (0, 3) and f (0, 4)) of the pixel point of the first cache region a which is used up is deleted, and the related information (f (3, 0), f (3, 1), f (3, 2), f (3, 3) and f (3, 4)) of the pixel point of the fourth row is stored into the first cache region a; after the related information (f (1, 0), f (1, 1), f (1, 2), f (1, 3) and f (1, 4)) of the pixel points of the first cache region b is used up, the related information (f (1, 0), f (1, 1), f (1, 2), f (1, 3) and f (1, 4)) of the pixel points of the first cache region b which is used up is deleted, and the related information (f (4, 0), f (4, 1), f (4, 2), f (4, 3) and f (4, 4)) of the pixel points of the fifth row is stored into the first cache region b; when the number of rows of the pixel point matrix is greater than 5 and/or the number of the first buffer areas is greater than 3, the method for buffering the pixel point matrix into the first buffer areas is similar to the method described above, and will not be described here.
It can be seen that, in the embodiment of the present application, while the image row data caching module caches data points, the image data selection module selects relevant information required for calculating the convolution of a target pixel point, and registers the relevant information in the image column data register module, and the three steps are performed in parallel, so that the data reading and caching speed is increased, and the speed of the whole calculation process is increased.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a template convolution calculating unit 200 according to an embodiment of the present application. The template convolution calculating unit 200 comprises an X-direction template convolution calculating module 210 and a Y-direction template convolution calculating module 220, wherein the X-direction template convolution calculating module 210 comprises at least a plurality of first multipliers and first adders, and the Y-direction template convolution calculating module 220 comprises at least a plurality of second multipliers and second adders;
the at least a plurality of first multipliers are used for calculating a first product of matrix elements in the convolution template in the X direction and the related information required by the convolution of the calculation target pixel points;
the at least a plurality of second multipliers are used for calculating second products of matrix elements in the convolution template in the Y direction and the related information required by the convolution of the calculation target pixel points;
the first adder is used for calculating the sum of the first products to obtain X-direction convolution;
and the second adder is used for calculating the sum of the second products to obtain the convolution in the Y direction.
Wherein the plurality of first multipliers are determined based on the size of the X convolution template and the plurality of second multipliers are determined based on the size of the Y convolution template.
For example, if the size of the X convolution template is 2 × 2,4 first multipliers are required; if the size of the X convolution template is 3X 3, 9 first multipliers are needed; if the size of the X convolution mask is 4X 4, 16 first multipliers are required.
In an implementation manner of the present application, the sizes of the X-direction convolution template and the Y-direction convolution template are both P × P, where P is a positive integer smaller than M and smaller than N, and P is an odd number, where:
the X-direction convolution template is as follows:
Figure BDA0002163559990000091
the Y-direction convolution template is:
Figure BDA0002163559990000092
the kernel x For the X-direction convolution template, the kernel y For the Y-direction convolution template, the mx 0,0 ,···,mx P-1,P-1 For the matrix elements in the X-direction convolution template, the my 0,0 ,···,my P-1,P-1 And the matrix elements in the convolution template in the Y direction are used.
For example, assuming that the size of the X-direction convolution template and the size of the Y-direction convolution template are both 3 × 3, the X-direction convolution template may be expressed as:
Figure BDA0002163559990000101
the Y-direction convolution template may be expressed as:
Figure BDA0002163559990000102
in an implementation manner of the present application, the apparatus further includes a calculation information determining unit, configured to determine, based on the X-direction convolution template and the Y-direction convolution template, relevant information required for calculating the convolution of the target pixel.
Further, if the target pixel point is (m, n), the calculation information determining unit is configured to determine, based on the X-direction convolution template and the Y-direction convolution template, that the relevant information required to calculate the convolution of the target pixel point is:
Figure BDA0002163559990000103
and if the relevant information required for calculating the convolution of the target pixel point comprises the relevant information of the pixel points except the relevant information of the M x N pixel points, setting the relevant information of the pixel points except the relevant information of the M x N pixel points as preset information.
For another example, assuming that P is 3, and the X-direction convolution template and the Y-direction convolution template are as described above, the correlation information of the pixels associated with the first pixel (0, 0) is determined as follows:
f(-1,-1)、f(-1,0)、f(-1,1)、
f(0,-1)、f(0,0)、f(0,1)、
f(1,-1)、f(1,0)、f(1,1);
in the correlation information of the pixels, if the correlation information of the M × N pixels does not include f (-1, -1), f (0, -1), f (1, -1), f (-1, 0), and f (-1, 1), then f (-1, -1) = f (0, -1) = f (1, -1) = f (-1, 0) = f (-1, 1) = k, and k is a predetermined pixel value.
The preset pixel value in the preset information may be, for example, 0,1, 2 or other values, which is not limited herein.
In an implementation manner of the present application, the X-direction template convolution calculating module 210 is configured to calculate an X-direction convolution based on a first formula, and the Y-direction template convolution calculating module 220 is configured to calculate a Y-direction convolution based on a second formula.
The first formula is:
Figure BDA0002163559990000111
Figure BDA0002163559990000112
the second formula is:
Figure BDA0002163559990000113
Figure BDA0002163559990000114
wherein, convx (m, n) is the X-direction convolution of any pixel, and Convy (m, n) is the Y-direction convolution of any pixel.
For example, the first formula includes P × P addition computations, requiring P × P adders, each adder computing an addition; the second formula also includes P x P addition calculations, which also require P x P adders, each of which calculates an addition.
It can be seen that in the embodiment of the present application, a plurality of multipliers calculate simultaneously, and each multiplier calculates one multiplication, so that the original calculation speed one by one is greatly reduced, and the calculation speed of the whole calculation process is increased.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a square sum calculation module 310 according to an embodiment of the present disclosure. The sum of squares calculation module 310 includes at least two third multipliers and a third adder;
one of the at least two third multipliers for calculating a square of the X-direction convolution;
another one of the at least two third multipliers for calculating a square of the Y-direction convolution;
the third adder is configured to calculate a sum of a square of the X-direction convolution and a square of the Y-direction convolution to obtain the first numerical value.
In one implementation of the present application, the gradient magnitude is determined based on a third formula, the third formula being:
Magnitide(m,n)=(Convx(m,n)*Convx(m,n)+Convy(m,n)*Convy(m,n)) 1/2
wherein, the Magnitide (m, n) is the gradient amplitude of any one target pixel point.
Wherein one of the at least two third multipliers is configured to calculate Convx (m, n) × Convx (m, n).
Wherein the other of the at least two third multipliers is used to calculate Convy (m, n) × Convy (m, n)).
The sum of squares calculation module 310 is configured to calculate Convx (m, n) × Convx (m, n) + Convy (m, n) × Convy (m, n).
It can be seen that, in the embodiment of the present application, the adder and the multiplier are used to calculate the sum of squares, compared with software, computer hardware does not need to report to a central processing unit CPU during the calculation process, then the CPU receives a corresponding instruction, and finally a related module is called to calculate, so that the calculation speed of the image gradient can be improved.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a square root calculating module 320 according to an embodiment of the present disclosure. The square root calculation module 320 is configured to convert a square root calculation into a plurality of first iterative calculations, where the first iterative calculations include addition calculations and multiplication calculations, and the square root calculation module includes a first register, at least two fourth multipliers, and a first subtractor;
the first register is used for storing a third numerical value;
one of the at least two fourth multipliers is configured to square the third value to obtain a fourth value;
the first subtractor is used for calculating the difference between a first constant and the fourth value to obtain a fifth value, wherein the first constant is a preset constant;
and the other one of the at least two fourth multipliers is used for calculating the sum of the third numerical value and the fifth numerical value to obtain a sixth numerical value, the sixth numerical value is a new third numerical value, and the gradient amplitude of the target pixel point is the third numerical value obtained through the multiple first iteration calculations.
In one implementation of the present application, the gradient magnitude is determined based on a third formula, the third formula being:
Magnitide(m,n)=(Convx(m,n)*Convx(m,n)+Convy(m,n)*Convy(m,n)) 1/2
wherein, the Magnitide (m, n) is the gradient amplitude of any pixel point.
The square root calculating module 320 is configured to calculate Magnitide (m, n).
It can be seen that, in the embodiment of the present application, the square root calculation is converted into the first iterative calculation for multiple times, and the square root calculation module includes the first register, the at least two fourth multipliers and the first subtractor, compared with software, computer hardware does not need to report to the central processing unit CPU in the calculation process, and then the CPU receives a corresponding instruction, and finally calls the relevant module to perform calculation, so that the calculation speed of the image gradient can be improved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a gradient amplitude calculation unit 300 according to an embodiment of the present disclosure. The gradient magnitude calculation unit includes a sum of squares calculation module 310 shown in fig. 4 and a square root calculation module 320 shown in fig. 5.
Wherein the sum of squares calculation module 310 comprises at least two third multipliers and a third adder; one of the at least two third multipliers for calculating a square of the X-direction convolution; another one of the at least two third multipliers for calculating a square of the Y-direction convolution; the third adder is configured to calculate a sum of a square of the X-direction convolution and a square of the Y-direction convolution to obtain the first numerical value.
The square root computation module 320 is configured to convert a square root computation into a plurality of first iterative computations, where the first iterative computations include addition computations and multiplication computations, and the square root computation module includes a first register, at least two fourth multipliers, and a first subtractor; the first register is used for storing a third numerical value, and the initial value of the third numerical value is the first numerical value; one of the at least two fourth multipliers for squaring the third value to obtain a fourth value; the first subtractor is used for calculating the difference between a first constant and the fourth value to obtain a fifth value, wherein the first constant is a preset constant; and the other one of the at least two fourth multipliers is used for calculating the sum of the third numerical value and the fifth numerical value to obtain a sixth numerical value, the sixth numerical value is a new third numerical value, and the gradient amplitude of the target pixel point is the third numerical value obtained through the multiple first iteration calculations.
In one implementation of the present application, the gradient magnitude is determined based on a third formula, the third formula being:
Magnitide(m,n)=(Convx(m,n)*Convx(m,n)+Convy(m,n)*Convy(m,n)) 1/2
wherein, the Magnitide (m, n) is the gradient amplitude of any pixel point.
The sum of squares calculation module 310 and the square root calculation module 320 are configured to calculate Magnitide (m, n) based on a third formula.
For example, assuming that the preset pixel value is 0, p is 3, the X-direction convolution template and the Y-direction convolution template are as described above, the correlation information of the first pixel point is f (0, 0), and the X-direction convolution of the first pixel point is determined based on the first formula as follows:
Convx(0,0)=mx 0,0 *f(-1,-1)+mx 0,1 *f(-1,0)+mx 0,2 *f(-1,1)+mx 1,0 *f(0,-1)+mx 1,1 *f(0,0)+mx 1,2 *f(0,1)+mx 2,0 *f(1,-1)+mx 2,1 *f(1,0)+mx 2,2 *f(1,0)
=mx 1,1 *f(0,0)+mx 1,2 *f(0,1)+mx 2,1 *f(1,0)+mx 2,2 *f(1,0)
and determining the Y-direction convolution of the first pixel point as follows based on a second formula:
Convy(0,0)=my 0,0 *f(-1,-1)+my 0,1 *f(-1,0)+my 0,2 *f(-1,1)+my 1,0 *f(0,-1)+my 1,1 *f(0,0)+my 1,2 *f(0,1)+my 2,0 *f(1,-1)+my 2,1 *f(1,0)+my 2,2 *f(1,0)
=my 1,1 *f(0,0)+my 1,2 *f(0,1)+my 2,1 *f(1,0)+my 2,2 *f(1,0)
determining the gradient amplitude of the first pixel point as follows based on a third formula:
Magnitide(0,0)=(Convx(0,0)*Convx(0,0)+Convy(0,0)*Convy(0,0)) 1/2
it can be seen that in the embodiment of the present application, the amplitude calculation is converted into the operation including addition, subtraction and multiplication, and the operation is performed by the adder, the subtractor and the multiplier, compared with software, computer hardware does not need to report to the central processing unit CPU during the calculation process, then the CPU receives the corresponding instruction, and finally the relevant module is called to perform the calculation, so that the calculation speed of the image gradient can be improved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a gradient angle calculation unit 400 according to an embodiment of the present disclosure. The gradient angle calculation unit 400 is configured to convert the gradient angle calculation into a plurality of second iterative calculations, where the second iterative calculations include addition calculations and/or subtraction calculations, and the gradient angle calculation unit 400 includes at least three second registers, at least three fourth adders, and a second subtractor;
a second register i, configured to store a seventh value, where an initial value of the seventh value is the X-direction convolution; a second register j, configured to store an eighth value, where an initial value of the eighth value is the Y-direction convolution; the second register k is used for storing a ninth value, and the initial value of the ninth value is a preset value; the second register i, the second register j and the second register k are all one of the at least three second registers;
an adder i, configured to calculate a sum of the seventh numerical value and a tenth numerical value to obtain an eleventh numerical value, where the eleventh numerical value is a new seventh numerical value, and the tenth numerical value is a numerical value obtained after shifting the eighth numerical value;
an adder j, configured to calculate a sum of the eighth numerical value and a twelfth numerical value to obtain a thirteenth numerical value, where the thirteenth numerical value is a new eighth numerical value, and the twelfth numerical value is a numerical value obtained by shifting the seventh numerical value;
an adder k, configured to calculate a sum of the ninth value and a fourteenth value to obtain a fifteenth value, where the fifteenth value is a new ninth value, the fourteenth value is an inverse trigonometric function value stored in a lookup table, and the adder i, the adder j, and the adder k are all one of the at least three fourth adders; or, the second subtractor is configured to calculate a difference between the ninth value and the fourteenth value to obtain a sixteenth value, where the sixteenth value is a new ninth value, and the gradient angle of the target pixel is a ninth value obtained through the second iterative computations.
For example, assuming that the preset pixel value is 0, p is 3, the X-direction convolution template and the Y-direction convolution template are as described above, the correlation information of the first target pixel point is f (0, 0), and the X-direction convolution of the first pixel point is determined based on the first formula as:
Convx(0,0)=mx 0,0 *f(-1,-1)+mx 0,1 *f(-1,0)+mx 0,2 *f(-1,1)+mx 1,0 *f(0,-1)+mx 1,1 *f(0,0)+mx 1,2 *f(0,1)+mx 2,0 *f(1,-1)+mx 2,1 *f(1,0)+mx 2,2 *f(1,0)
=mx 1,1 *f(0,0)+mx 1,2 *f(0,1)+mx 2,1 *f(1,0)+mx 2,2 *f(1,0)
and determining the Y-direction convolution of the first pixel point as follows based on a second formula:
Convy(0,0)=my 0,0 *f(-1,-1)+my 0,1 *f(-1,0)+my 0,2 *f(-1,1)+my 1,0 *f(0,-1)+my 1,1 *f(0,0)+my 1,2 *f(0,1)+my 2,0 *f(1,-1)+my 2,1 *f(1,0)+my 2,2 *f(1,0)
=my 1,1 *f(0,0)+my 1,2 *f(0,1)+my 2,1 *f(1,0)+my 2,2 *f(1,0)
determining the gradient angle of the first pixel point as follows based on a fourth formula:
Theta(0,0)=arctan(Convy(0,0)/Convx(0,0))。
it can be seen that in the embodiment of the present application, the angle calculation is converted into the operation including addition, subtraction and multiplication, and the operation is removed by the adder, the subtractor and the multiplier, compared with software, computer hardware does not need to report to the central processing unit CPU during the calculation process, then the CPU receives the corresponding instruction, and finally the relevant module is called to perform calculation, so that the calculation speed of the image gradient can be improved.
Referring to fig. 8, fig. 8 is a schematic structural diagram of a gradient data output buffer unit 500 according to an embodiment of the present disclosure. The gradient data output cache unit comprises K second cache regions, each second cache region is used for caching the gradient amplitude and the gradient angle of N pixel points, N pixel points corresponding to the gradient amplitude and the gradient angle of the N pixel points cached in each second cache region are adjacent, and the target pixel point comprises the N pixel points.
In an implementation manner of the present application, the gradient data output buffer unit 500 is specifically configured to:
after the gradient amplitude and the gradient angle of each pixel point of one first cache region are calculated, caching the calculated gradient amplitude and gradient angle of each pixel point of the first cache region into a second cache region;
when each K second cache regions are cached, outputting the gradient amplitudes and gradient angles of the K second cache regions, and deleting the gradient amplitudes and gradient angles in the K second cache regions;
and caching the calculated and uncached gradient amplitudes and gradient angles to the K second cache regions again and outputting the same until the gradient amplitudes and gradient angles of the M x N pixel points are output.
For example, assuming that M is 5, n is 5, and k is 3, the calculated gradient magnitudes and gradient angles of the pixel points (f (0, 0), f (0, 1), f (0, 2), f (0, 3), and f (0, 4)) of the first buffer a are buffered in the second buffer d, the calculated gradient magnitudes and gradient angles of the pixel points (f (1, 0), f (1, 1), f (1, 2), f (1, 3), and f (1, 4)) of the first buffer b are buffered in the second buffer e, the calculated gradient magnitudes and gradient angles of the pixel points (f (2, 0), f (2, 1), f (2, 2), f (2, 3), and f (2, 4)) of the first buffer c are buffered in the second buffer f, and the gradient magnitudes and gradient angles of the pixel points (f (2, 0), f (2, 1), f (2, 3), and f) of the second buffer d, e, and f are output, and the gradient magnitudes and gradient angles of the second buffer points d, e, and f in the second buffer f are deleted; then, the calculated gradient amplitudes and gradient angles of the pixel points (f (3, 0), f (3, 1), f (3, 2), f (3, 3) and f (3, 4)) of the first buffer area a are buffered to a second buffer area d, the calculated gradient amplitudes and gradient angles of the pixel points (f (4, 0), f (4, 1), f (4, 2), f (4, 3) and f (4, 4)) of the first buffer area b are buffered to a second buffer area e, then the gradient amplitudes and gradient angles of the second buffer areas d and e are output, and the gradient amplitudes and gradient angles in the second buffer areas d and e are deleted; when the number of rows of the pixel point matrix is greater than 5 and/or the number of the first buffer area is greater than 3, the method of buffering to the second buffer area and outputting is similar to the method described above, and will not be described here.
It can be seen that, in the embodiment of the present application, the calculated gradient data of the pixel point cache value is output to the cache unit, and when K × N data is cached, the data is output once, so that the output time is saved compared with one-by-one output, and the speed of the whole calculation process is increased.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an image gradient calculating apparatus according to an embodiment of the present disclosure. The apparatus comprises an image data input buffer unit 100 shown in fig. 2, a template convolution calculation unit 200 shown in fig. 3, a gradient amplitude calculation unit 300 shown in fig. 6, a gradient angle calculation unit 400 shown in fig. 7 and a gradient data output buffer unit 500 shown in fig. 8, wherein the template convolution calculation unit 200 is respectively connected with the image data input buffer unit 100, the gradient amplitude calculation unit 300 and the gradient angle calculation unit 400, and the gradient data output buffer unit 500 is respectively connected with the gradient amplitude calculation unit 300 and the gradient angle calculation unit 400; the image data input buffer unit 100 is configured to buffer relevant information of M × N pixel points included in an input image, where M and N are integers greater than 1; the template convolution calculating unit 200 is configured to, in a process that the image data input buffer unit buffers the relevant information of the pixel, read relevant information required for calculating the convolution of the target pixel from the image data input buffer unit, and calculate the convolution of the target pixel; the gradient amplitude calculation unit 300 is configured to obtain a convolution of the target pixel point, and calculate a gradient amplitude of the target pixel point; the gradient angle calculation unit 400 is configured to obtain the convolution of the target pixel point, and calculate a gradient angle of the target pixel point; the gradient data output buffer unit 500 is configured to buffer the gradient amplitude of the target pixel and the gradient angle of the target pixel.
The image data input buffer unit 100 includes an image row data buffer module 110, an image data selection module 120, and an image column data register module 130, where the image row data buffer module 110 includes K first buffer areas, where K is an integer greater than 1, the image row data buffer module 110 is connected to the image data selection module 120, and the image data selection module 120 is connected to the image column data register module 130; the image line data caching module 110 is configured to cache relevant information of K × N pixels in the relevant information of the M × N pixels in the K first cache regions, where each first cache region is configured to cache relevant information of N pixels, N pixels corresponding to the relevant information of the N pixels cached in each first cache region are adjacent to each other, and M is greater than K; the image line data caching module is further used for deleting the related information of the pixel points of the first cache region after the related information of the pixel points of the first cache region is used up, and caching the related information of the pixel points which are not cached in the K first cache regions into the first cache region; the image data selection module 120 is configured to select, from the relevant information of the pixels cached to the K first cache regions, relevant information required for calculating convolution of a target pixel; the image column data register module 130 is configured to register related information required for convolution of the calculation target pixel point.
The template convolution calculation unit 200 includes an X-direction template convolution calculation module 210 and a Y-direction template convolution calculation module 220, where the X-direction template convolution calculation module 210 includes at least a plurality of first multipliers and first adders, and the Y-direction template convolution calculation module 220 includes at least a plurality of second multipliers and second adders; the at least a plurality of first multipliers are used for calculating a first product of matrix elements in the convolution template in the X direction and the related information required by the convolution of the calculation target pixel points; the at least a plurality of second multipliers are used for calculating a second product of matrix elements in the convolution template in the Y direction and the related information required by the convolution of the calculation target pixel point; the first adder is used for calculating the sum of the first products to obtain X-direction convolution; and the second adder is used for calculating the sum of the second products so as to obtain the convolution in the Y direction.
Wherein the gradient magnitude calculation unit 300 comprises a sum of squares calculation module 310 and a square root calculation module 320, the sum of squares calculation module 310 being connected to the square root calculation module 320; the sum of squares calculation module 310 is configured to calculate a first value, where the first value is a sum of a square of the X-direction convolution and a square of the Y-direction convolution; the square root calculating module 320 is configured to calculate a second numerical value, where the second numerical value is a square root of the first numerical value, and the second numerical value is a gradient amplitude of the target pixel point.
Wherein the square sum computation module 310 comprises at least two third multipliers and a third adder; one of the at least two third multipliers for calculating a square of the X-direction convolution; another one of the at least two third multipliers for calculating a square of the Y-direction convolution; the third adder is configured to calculate a sum of a square of the X-direction convolution and a square of the Y-direction convolution to obtain the first numerical value.
The square root calculation module 320 is configured to convert a square root calculation into a plurality of first iterative calculations, where the first iterative calculations include addition calculations and multiplication calculations, and the square root calculation module 320 includes a first register, at least two fourth multipliers, and a first subtractor; the first register is used for storing a third numerical value, and the initial value of the third numerical value is the first numerical value; one of the at least two fourth multipliers is configured to square the third value to obtain a fourth value;
the first subtractor is used for calculating the difference between a first constant and the fourth value to obtain a fifth value, wherein the first constant is a preset constant; and the other one of the at least two fourth multipliers is used for calculating the sum of the third numerical value and the fifth numerical value to obtain a sixth numerical value, the sixth numerical value is a new third numerical value, and the gradient amplitude of the target pixel point is the third numerical value obtained through the multiple first iteration calculations.
Wherein the gradient angle calculation unit 400 is configured to convert the gradient angle calculation into a plurality of second iterative calculations, the second iterative calculations include addition calculations and/or subtraction calculations, and the gradient angle calculation unit 400 includes at least three second registers, at least three fourth adders, and a second subtractor; a second register i, configured to store a seventh value, where an initial value of the seventh value is the X-direction convolution; a second register j, configured to store an eighth value, where an initial value of the eighth value is the Y-direction convolution; the second register k is used for storing a ninth value, and the initial value of the ninth value is a preset value; the second register i, the second register j and the second register k are all one of the at least three second registers; an adder i, configured to calculate a sum of the seventh numerical value and a tenth numerical value to obtain an eleventh numerical value, where the eleventh numerical value is a new seventh numerical value, and the tenth numerical value is a numerical value obtained after shifting the eighth numerical value; an adder j, configured to calculate a sum of the eighth numerical value and a twelfth numerical value to obtain a thirteenth numerical value, where the thirteenth numerical value is a new eighth numerical value, and the twelfth numerical value is a numerical value obtained by shifting the seventh numerical value; an adder k, configured to calculate a sum of the ninth value and a fourteenth value to obtain a fifteenth value, where the fifteenth value is a new ninth value, the fourteenth value is an inverse trigonometric function value stored in a lookup table, and the adder i, the adder j, and the adder k are all one of the at least three fourth adders; or, the second subtractor is configured to calculate a difference between the ninth value and the fourteenth value to obtain a sixteenth value, where the sixteenth value is a new ninth value, and the gradient angle of the target pixel is a ninth value obtained through the second iterative computations.
The gradient data output buffer unit 500 includes K second buffer areas, each of the second buffer areas is configured to buffer gradient amplitudes and gradient angles of N pixel points, N pixel points corresponding to the gradient amplitudes and gradient angles of the N pixel points buffered in each of the second buffer areas are adjacent to each other, and the target pixel point includes the N pixel points.
It can be seen that, in the embodiment of the present application, the image gradient calculation apparatus includes an image data input buffer unit, a template convolution calculation unit, a gradient amplitude calculation unit, a gradient angle calculation unit, and a gradient data output buffer unit, all of the five units are computer hardware, and the convolution, the gradient amplitude, and the gradient angle of each pixel point are calculated by the relevant computer hardware respectively.
It should be noted that, for the sake of simplicity, the embodiments of the present application are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some interfaces, indirect coupling or communication connection between devices or units, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application with specific examples, and the above description of the embodiments is only provided to help understand the present application and its core ideas; meanwhile, for a person skilled in the art, according to the idea of the present application, the specific embodiments and the application range may be changed, and in view of the above, the content of the present specification should not be construed as limiting the present application.

Claims (8)

1. An image gradient calculation device is characterized by comprising an image data input buffer unit, a template convolution calculation unit, a gradient amplitude calculation unit, a gradient angle calculation unit and a gradient data output buffer unit, wherein the template convolution calculation unit is respectively connected with the image data input buffer unit, the gradient amplitude calculation unit and the gradient angle calculation unit, and the gradient data output buffer unit is respectively connected with the gradient amplitude calculation unit and the gradient angle calculation unit;
the image data input cache unit is used for caching relevant information of M x N pixel points included in an input image, wherein M and N are integers larger than 1;
the template convolution calculating unit is used for reading relevant information required for calculating the convolution of a target pixel point from the image data input cache unit and calculating the convolution of the target pixel point in the process of caching the relevant information of the pixel point by the image data input cache unit;
the gradient amplitude calculation unit is used for acquiring the convolution of the target pixel point and calculating the gradient amplitude of the target pixel point;
the gradient angle calculation unit is used for acquiring the convolution of the target pixel point and calculating the gradient angle of the target pixel point;
the gradient data output cache unit is used for caching the gradient amplitude of the target pixel point and the gradient angle of the target pixel point;
the template convolution calculation unit comprises an X-direction template convolution calculation module and a Y-direction template convolution calculation module, the X-direction template convolution calculation module comprises at least a plurality of first multipliers and first adders, and the Y-direction template convolution calculation module comprises at least a plurality of second multipliers and second adders;
the gradient amplitude calculation unit comprises a square sum calculation module and a square root calculation module, and the square sum calculation module is connected with the square root calculation module;
the gradient angle calculation unit comprises at least three second registers, at least three fourth adders and a second subtracter.
2. The apparatus according to claim 1, wherein the image data input buffer unit comprises an image row data buffer module, an image data selection module and an image column data register module, the image row data buffer module comprises K first buffer areas, K is an integer greater than 1, the image row data buffer module is connected with the image data selection module, and the image data selection module is connected with the image column data register module;
the image line data caching module is used for caching the related information of K pixel points in the related information of the M pixel points to K first caching regions, each first caching region is used for caching the related information of the N pixel points, the N pixel points corresponding to the related information of the N pixel points cached in each first caching region are adjacent, and M is larger than K;
the image line data caching module is further configured to delete the used related information of the pixel points of the first cache region after the related information of the pixel points of the first cache region is used up, and cache the related information of the pixel points which are not cached to the K first cache regions into the first cache region;
the image data selection module is used for selecting relevant information required for calculating the convolution of the target pixel point from the relevant information of the pixel points cached to the K first cache regions;
and the image column data register module is used for registering the related information required by the convolution of the calculation target pixel point.
3. The apparatus according to claim 1, wherein the at least a plurality of first multipliers are configured to calculate a first product of matrix elements in an X-direction convolution template and the related information required for the convolution of the calculation target pixel;
the at least a plurality of second multipliers are used for calculating second products of matrix elements in the convolution template in the Y direction and the related information required by the convolution of the calculation target pixel points;
the first adder is used for calculating the sum of the first products to obtain X-direction convolution;
and the second adder is used for calculating the sum of the second products to obtain the convolution in the Y direction.
4. The apparatus of claim 1, wherein the sum of squares calculation module is configured to calculate a first value, and the first value is a sum of a square of the X-direction convolution and a square of the Y-direction convolution;
and the square root calculation module is used for calculating a second numerical value, wherein the second numerical value is the square root of the first numerical value, and the second numerical value is the gradient amplitude of the target pixel point.
5. The apparatus of claim 4, wherein the sum of squares calculation module comprises at least two third multipliers and a third adder;
one of the at least two third multipliers for calculating a square of the X-direction convolution;
another one of the at least two third multipliers for calculating a square of the Y-direction convolution;
the third adder is configured to calculate a sum of a square of the X-direction convolution and a square of the Y-direction convolution to obtain the first numerical value.
6. The apparatus of claim 5, wherein the square root computation module is configured to convert a square root computation into a plurality of first iterative computations, the first iterative computations including an addition computation and a multiplication computation, the square root computation module including a first register, at least two fourth multipliers, and a first subtractor;
the first register is used for storing a third numerical value, and the initial value of the third numerical value is the first numerical value;
one of the at least two fourth multipliers for squaring the third value to obtain a fourth value;
the first subtractor is used for calculating the difference between a first constant and the fourth value to obtain a fifth value, wherein the first constant is a preset constant;
and the other one of the at least two fourth multipliers is used for calculating the sum of the third numerical value and the fifth numerical value to obtain a sixth numerical value, the sixth numerical value is a new third numerical value, and the gradient amplitude of the target pixel point is the third numerical value obtained through the multiple first iteration calculations.
7. The apparatus according to claim 1, wherein the gradient angle calculation unit is configured to translate a gradient angle calculation into a plurality of second iterative calculations, the second iterative calculations comprising addition calculations and/or subtraction calculations;
a second register i, configured to store a seventh numerical value, where an initial value of the seventh numerical value is the X-direction convolution; a second register j, configured to store an eighth value, where an initial value of the eighth value is the Y-direction convolution; the second register k is used for storing a ninth value, and the initial value of the ninth value is a preset value; the second register i, the second register j and the second register k are all one of the at least three second registers;
an adder i, configured to calculate a sum of the seventh numerical value and a tenth numerical value to obtain an eleventh numerical value, where the eleventh numerical value is a new seventh numerical value, and the tenth numerical value is a numerical value obtained after the eighth numerical value is shifted;
an adder j, configured to calculate a sum of the eighth numerical value and a twelfth numerical value to obtain a thirteenth numerical value, where the thirteenth numerical value is a new eighth numerical value, and the twelfth numerical value is a numerical value obtained by shifting the seventh numerical value;
an adder k, configured to calculate a sum of the ninth value and a fourteenth value to obtain a fifteenth value, where the fifteenth value is a new ninth value, the fourteenth value is an inverse trigonometric function value stored in a lookup table, and the adder i, the adder j, and the adder k are all one of the at least three fourth adders; or, the second subtractor is configured to calculate a difference between the ninth value and the fourteenth value to obtain a sixteenth value, where the sixteenth value is a new ninth value, and the gradient angle of the target pixel is a ninth value obtained through the second iterative computations.
8. The apparatus according to claim 7, wherein the gradient data output buffer unit includes K second buffer areas, each second buffer area is used for buffering the gradient amplitude and the gradient angle of N pixel points, and N pixel points corresponding to the gradient amplitude and the gradient angle of N pixel points buffered in each second buffer area are adjacent, and the target pixel point includes the N pixel points.
CN201910739819.2A 2019-08-12 2019-08-12 Image gradient calculation device Active CN110610451B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910739819.2A CN110610451B (en) 2019-08-12 2019-08-12 Image gradient calculation device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910739819.2A CN110610451B (en) 2019-08-12 2019-08-12 Image gradient calculation device

Publications (2)

Publication Number Publication Date
CN110610451A CN110610451A (en) 2019-12-24
CN110610451B true CN110610451B (en) 2023-04-07

Family

ID=68889805

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910739819.2A Active CN110610451B (en) 2019-08-12 2019-08-12 Image gradient calculation device

Country Status (1)

Country Link
CN (1) CN110610451B (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103020889A (en) * 2012-12-04 2013-04-03 江南大学 Method and device for image gradient computation
CN106504182B (en) * 2016-11-02 2019-11-08 山东正晨科技股份有限公司 A kind of extraction of straight line system based on FPGA
CN108205680B (en) * 2017-12-29 2020-02-04 深圳云天励飞技术有限公司 Image feature extraction integrated circuit, method and terminal
CN108198125B (en) * 2017-12-29 2021-10-08 深圳云天励飞技术有限公司 Image processing method and device

Also Published As

Publication number Publication date
CN110610451A (en) 2019-12-24

Similar Documents

Publication Publication Date Title
CN111860398B (en) Remote sensing image target detection method and system and terminal equipment
CN107610146B (en) Image scene segmentation method and device, electronic equipment and computer storage medium
US11328395B2 (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN109194878B (en) Video image anti-shake method, device, equipment and storage medium
CN113870293A (en) Image processing method, image processing device, electronic equipment and storage medium
US10402196B2 (en) Multi-dimensional sliding window operation for a vector processor, including dividing a filter into a plurality of patterns for selecting data elements from a plurality of input registers and performing calculations in parallel using groups of the data elements and coefficients
CN111984189B (en) Neural network computing device, data reading method, data storage method and related equipment
CN110956131A (en) Single-target tracking method, device and system
CN111476718A (en) Image amplification method and device, storage medium and terminal equipment
CN111814957A (en) Neural network operation method and related equipment
CN114493988A (en) Image blurring method, image blurring device and terminal equipment
CN111931937B (en) Gradient updating method, device and system of image processing model
CN110210279B (en) Target detection method, device and computer readable storage medium
CN110610451B (en) Image gradient calculation device
CN108198125B (en) Image processing method and device
CN113468469A (en) Convolution processing method and device of feature graph executed by computer and electronic equipment
WO2024045665A1 (en) Multiple-point multiplication operation system and method, and graphics processor, electronic apparatus and device
TW201832178A (en) Image recognition accelerator system which is realized on a FPGA chip through a SIFT image recognition algorithm to reduce the hardware calculation cost
US11830114B2 (en) Reconfigurable hardware acceleration method and system for gaussian pyramid construction
CN111353597A (en) Target detection neural network training method and device
Siva et al. A low cost high performance VLSI architecture for image scaling in multimedia applications
US6119140A (en) Two-dimensional inverse discrete cosine transform circuit and microprocessor realizing the same and method of implementing 8×8 two-dimensional inverse discrete cosine transform
CN113808020A (en) Image processing method and apparatus
CN111626938A (en) Image interpolation method, image interpolation device, terminal device, and storage medium
CN112712461A (en) Image deconvolution processing method and device and terminal equipment

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
GR01 Patent grant
GR01 Patent grant