Image recognition system and image preprocessing method of neural network
Patent Information
- Application Number
- CN202311193059.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art is difficult to perform image segmentation and rotation processing simultaneously in an image recognition system, and a large memory space is required to store the entire image.
By introducing a preprocessing circuit in the image recognition system, each pixel is classified using segmentation specifications and rotation angles, and the corresponding memory address of the pixel in the target sub-map to which it belongs is calculated based on the rotation angle, and the pixel data is stored in the memory in sequence.
It is realized that without increasing memory space, the image recognition system can segment and rotate the image simultaneously, reducing the memory demand space.
Smart Images

Figure CN119648977A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an image recognition system and an image preprocessing method, and in particular to a neural network image recognition system and an image preprocessing method, which can simultaneously segment and rotate an image, and store the segmented and rotated sub-images of the image in a memory in sequence, thereby reducing the required memory space. Background Art
[0002] In one of the prior art solutions, a neural network image recognition system can store the entire image obtained by the image sensor in a memory. Then, the image recognition system can calculate the memory address of the sub-image after the image is rotated and segmented through a digital signal processor (DSP), and extract the sub-image from the memory to send it to a neural network processing unit (NPU) for recognition. In this case, the neural network image recognition system increases the cost of the digital signal processor and requires a larger memory space to store the entire image.
[0003] In another solution of the prior art, the neural network image recognition system can rotate the entire image obtained by the image sensor through the first layer of preprocessing circuit and store it in the memory. Then, the neural network image recognition system can extract the rotated image stored in the memory through the second layer of preprocessing circuit, and segment the sub-images to send to the neural network processing unit for recognition. In this case, even if the neural network image recognition system can save the cost of the digital signal processor, it still requires a large memory space to store the entire rotated image, and it is impossible to segment and rotate the image at the same time. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a neural network image recognition system and an image preprocessing method to address the deficiencies in the prior art, which can simultaneously segment and rotate an image, and store the segmented and rotated sub-images of the image in sequence in a memory, thereby reducing the required memory space.
[0005] In order to solve the above technical problems, one of the technical solutions adopted by the present invention is to provide a neural network image recognition system. The neural network image recognition system includes a memory, an image sensor, a preprocessing circuit and a neural network processing unit. The image sensor is configured to obtain an image including a plurality of pixels. The image is divided into a plurality of initial sub-images according to a segmentation specification, and the initial sub-images are rotated by a rotation angle to form a plurality of target sub-images. The preprocessing circuit is coupled to the image sensor and the memory, and is configured to execute a preprocessing image program in the process of sequentially obtaining pixel data. The preprocessing image program includes the following steps: for each pixel, classifying the pixel according to the segmentation specification and the rotation angle, so as to classify each pixel as belonging to at least one target sub-image; and for each pixel, calculating the corresponding memory address of the pixel in the target sub-image to which it belongs according to the rotation angle, and storing the pixel data in the memory according to the memory address, so as to store the target sub-image in the memory in sequence. The neural network processing unit is coupled to the memory, and is configured to extract one of the stored target sub-images from the memory for recognition.
[0006] In order to solve the above technical problems, another technical solution adopted by the present invention is to provide an image preprocessing method. The image preprocessing method is applicable to a neural network image recognition system, and the image recognition system includes a memory, an image sensor, a preprocessing circuit and a neural network processing unit. The image sensor is configured to obtain an image including a plurality of pixels, and the image is divided into a plurality of initial sub-images according to a segmentation specification, and the initial sub-images are rotated by a rotation angle to form a plurality of target sub-images. The preprocessing circuit is configured to perform a preprocessing image method in the process of sequentially obtaining pixel data, and the preprocessing image method includes the following steps: for each pixel, classifying the pixel according to the segmentation specification and the rotation angle, so as to classify each pixel as belonging to at least one target sub-image; and for each pixel, calculating the corresponding memory address of the pixel in the target sub-image to which it belongs according to the rotation angle, and storing the pixel data in the memory according to the memory address, so as to store the target sub-image in the memory in sequence. The neural network processing unit is coupled to the memory, and is configured to extract one of the stored target sub-images from the memory for recognition.
[0007] To further understand the features and technical contents of the present invention, please refer to the following detailed description and drawings of the present invention. However, the drawings provided are only for reference and description and are not intended to limit the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 4 is a functional block diagram of a neural network image recognition system according to an embodiment of the present invention.
[0009] Figure 2It is a schematic diagram of dividing an image into multiple initial sub-images according to a segmentation specification according to an embodiment of the present invention.
[0010] Figure 3 It is a schematic diagram of forming multiple target sub-graphs after an initial sub-graph is rotated by a rotation angle according to an embodiment of the present invention.
[0011] Figure 4 It is a flowchart of the steps of the image preprocessing method according to an embodiment of the present invention.
[0012] Figure 5 is a flowchart of the address conversion procedure according to an embodiment of the present invention.
[0013] Figure 6 It is a schematic diagram of calculating the memory address corresponding to a pixel in the target sub-image according to an embodiment of the present invention.
[0014] Explanation of symbols
[0015] 1: Image recognition system
[0016] 11: Image sensor
[0017] 12: First-in-first-out memory
[0018] 13: Preprocessing circuit
[0019] 14: Memory
[0020] 15: Neural network processing unit
[0021] Im: Image
[0022] TL: horizontal length
[0023] TW: vertical length
[0024] P0~P76: Pixels
[0025] A1~A4: Initial sub-graphs
[0026] B1~B4:Target subgraph
[0027] S410~S420,S510~S530: Process steps DETAILED DESCRIPTION
[0028] The following is an explanation of the implementation of the present invention through specific embodiments. Those skilled in the art can understand the advantages and effects of the present invention from the content provided in this specification. The present invention can be implemented or applied through other different specific embodiments, and the details in this specification can also be modified and changed in various ways based on different viewpoints and applications without departing from the concept of the present invention. In addition, the drawings of the present invention are only simple schematic illustrations and are not depicted according to actual dimensions. It is stated in advance. The following implementations will further explain the relevant technical content of the present invention in detail, but the content provided is not intended to limit the scope of protection of the present invention.
[0029] See also Figure 1 , Figure 1 FIG. 1 is a functional block diagram of a neural network image recognition system according to an embodiment of the present invention. Figure 1 As shown, the neural network image recognition system 1 includes an image sensor 11, a preprocessing circuit 13, a memory 14, and a neural network processing unit 15. It should be noted that the neural network processing unit 15 may include a processor equipped with a neural network computing engine, but the present invention does not limit the specific implementation of the neural network processing unit 15. In addition, the image sensor 11 is configured to obtain an image including a plurality of pixels.
[0030] Specifically, the image acquired by the image sensor 11 can be divided into a plurality of initial sub-images according to the segmentation specification, and the initial sub-images can be rotated by a rotation angle to form a plurality of target sub-images. Figure 2 and Figure 3 , Figure 2 is a schematic diagram of dividing an image into a plurality of initial sub-images according to a segmentation specification according to an embodiment of the present invention, Figure 3 It is a schematic diagram of forming multiple target sub-graphs after the initial sub-graph is rotated by a rotation angle according to an embodiment of the present invention.
[0031] like Figure 2 As shown, the image Im obtained by the image sensor 11 may have a horizontal length TL and a vertical length TW in units of pixels. However, for the convenience of the following description, the horizontal length TL and the vertical length TW of this embodiment will be taken as 11 and 7 respectively. Therefore, the image Im of this embodiment may include 77 pixels P0-P76, and may be divided into four initial sub-images A1-A4 according to the segmentation specification, but the present invention is not limited thereto.
[0032] It can be seen that the segmentation specification of this embodiment can define the position of each initial sub-image in the image Im, and define the horizontal length and vertical length of each initial sub-image in pixels. In addition, the rotation angle can be 0 degrees, 90 degrees counterclockwise, 180 degrees counterclockwise, or 270 degrees counterclockwise. However, for the convenience of the following description, the rotation angle of this embodiment will be 90 degrees counterclockwise as an example. Therefore, if Figure 3As shown, the initial sub-graphs A1-A4 of this embodiment can be rotated by a rotation angle to form corresponding four target sub-graphs B1-B4, but the present invention is not limited thereto.
[0033] It should be noted that the image sensor 11 outputs the data of pixels P0 to P76 in sequence. In addition, the pre-processing circuit 13 is coupled to the image sensor 11 and the memory 14, and obtains the data of pixels P0 to P76 in sequence. However, in order to achieve the simultaneous segmentation and rotation processing of the image Im, and to store the segmented and rotated sub-images of the image Im in the memory 14 in sequence, the pre-processing circuit 13 is configured to perform the image pre-processing method of the embodiment of the present invention in the process of sequentially obtaining the data of pixels P0 to P76.
[0034] Please also read Figure 4 , Figure 4 FIG. 1 is a flowchart of the steps of the image preprocessing method according to an embodiment of the present invention. Figure 4 As shown, the image preprocessing method of this embodiment includes the following steps:
[0035] Step S410: for each pixel, classify the pixel according to the segmentation specification and the rotation angle, so as to classify each pixel as belonging to at least one target sub-image; and
[0036] Step S420: For each pixel, calculate the memory address corresponding to the pixel in the target sub-image according to the rotation angle, and store the pixel data in the memory according to the memory address, so as to store multiple target sub-images in the memory in sequence.
[0037] Specifically, the preprocessing circuit 13 can be implemented by hardware (such as a processor and an internal memory) in combination with software and / or firmware, but the present invention does not limit the specific implementation of the preprocessing circuit 13. In addition, the image preprocessing method of this embodiment can be implemented by a computer program. In other words, the preprocessing circuit 13 can be configured to execute the image preprocessing program including the above steps in the process of sequentially acquiring the data of pixels P0-P76.
[0038] like Figure 2 and Figure 3 As shown, when the data of pixel P0 is obtained, the pre-processing circuit 13 can classify the pixel P0 as belonging to the target sub-image B1 according to the segmentation specification and the rotation angle, and calculate the memory address corresponding to the pixel P0 in the target sub-image B1 according to the rotation angle, and store the data of the pixel P0 in the memory 14 according to the memory address.
[0039] Furthermore, each pixel in the image Im has a pixel coordinate in units of pixels, and includes an x-axis coordinate value and a y-axis coordinate value. Figure 2As shown, pixel P0 has x-axis coordinate values and y-axis coordinate values of 0 and 0 respectively in image Im, and pixel P1 has x-axis coordinate values and y-axis coordinate values of 1 and 0 respectively in image Im, and so on, pixel P76 has x-axis coordinate values and y-axis coordinate values of 10 and 6 respectively in image Im.
[0040] In addition, the segmentation specification of this embodiment can also define the x-axis coordinate value range and y-axis coordinate value range of each initial sub-image in the image Im according to the horizontal length, vertical length and position of each initial sub-image in the image Im. Therefore, for each pixel, when the x-axis coordinate value and y-axis coordinate value of the pixel Pα in the image Im fall into the x-axis coordinate value range and y-axis coordinate value range of one of the initial sub-images Aγ (that is, in this embodiment, α is an integer from 0 to 76, and γ is an integer from 1 to 4) in the image Im, the pre-processing circuit 13 will classify the pixel Pα as belonging to the target sub-image Bγ formed by the initial sub-image Aγ after being rotated by the rotation angle.
[0041] like Figure 2 As shown, the horizontal length and vertical length of the initial sub-image A1 can be 7 and 4 respectively, and according to the horizontal length, vertical length and position of the initial sub-image A1 in the image Im, the x-axis coordinate value range Rx1 and the y-axis coordinate value range Ry1 of the initial sub-image A1 in the image Im can be 0≤Rx1≤(7-1) and 0≤Ry1≤(4-1) respectively. Since the x-axis coordinate value and the y-axis coordinate value of the pixel P0 in the image Im fall into the x-axis coordinate value range Rx1 and the y-axis coordinate value range Ry1 of the initial sub-image A1 in the image Im respectively, the pre-processing circuit 13 will classify the pixel P0 as belonging to the target sub-image B1 formed by the rotation angle after the initial sub-image A1 is rotated.
[0042] On the other hand, the pre-processing circuit 13 is configured to perform an address conversion procedure in the process of calculating the memory address corresponding to the pixel Pα in the corresponding target sub-image Bγ according to the rotation angle. Figure 5 , Figure 5 1 is a flowchart of the steps of the address conversion procedure of an embodiment of the present invention. Figure 5 As shown, the address conversion procedure of this embodiment includes the following steps:
[0043] Step S510: Determine whether the pixel is the first pixel obtained by the pre-processing circuit in the target sub-image. If so, the address conversion process enters step S520; if not, the address conversion process enters step S530.
[0044] Step S520: Calculate a first offset according to the rotation angle, initialize the count value corresponding to the target sub-image to 0, and calculate the memory address corresponding to the pixel in the target sub-image according to the first offset and the starting memory address.
[0045] Step S530: Calculate a second offset according to the rotation angle and the count value corresponding to the target sub-image, and calculate a memory address corresponding to the pixel in the target sub-image according to the second offset and the memory address corresponding to the previous pixel obtained by the pre-processing circuit in the target sub-image.
[0046] Specifically, the first offset calculated according to the rotation angle can be expressed by the following formula:
[0047]
[0048] off1 is the first offset, FW is the vertical length of the target sub-image Bγ to which the pixel Pα belongs, FL is the horizontal length of the target sub-image Bγ to which the pixel Pα belongs, and R is the rotation angle. It should be noted that R=90 ° , R=180 ° and R = 270 ° That is, the rotation angles are 90 degrees counterclockwise, 180 degrees counterclockwise, and 270 degrees counterclockwise respectively.
[0049] In addition, the memory address corresponding to the pixel Pα in the target sub-image Bγ can be calculated according to the first offset off1 and the starting memory address and can be expressed by the following formula:
[0050] addr = start_addr + off1;
[0051] addr is the memory address corresponding to the pixel Pα in the target sub-image Bγ, and start_addr is the starting memory address.
[0052] On the other hand, the pre-processing circuit 13 executes an algorithm to calculate the second offset according to the rotation angle and the count value corresponding to the target sub-image Bγ, and the algorithm is expressed as follows:
[0053] °
[0054] R=0:
[0055] off2 = 1;
[0056] R=90 ° :
[0057] If (AC=FW-1)
[0058] {
[0059] off2 = FL * (FW - 1) + 1;
[0060] AC=0;
[0061] }
[0062] otherwise
[0063] {
[0064] off2 = -FL;
[0065] AC=AC+1;
[0066] }
[0067] R=180 ° :
[0068] off2 = -1;
[0069] R=270 ° :
[0070] If (AC=FW-1)
[0071] {
[0072] off2 = -(FL*(FW-1)+1);
[0073] AC=0;
[0074] }
[0075] otherwise
[0076] {
[0077] off2 = FL;
[0078] AC=AC+1;
[0079] };
[0080] off2 is the second offset, and AC is the count value corresponding to the target sub-image Bγ. In addition, the memory address corresponding to the pixel Pα in the target sub-image Bγ can be calculated based on the second offset off2 and the memory address corresponding to the previous pixel obtained by the pre-processing circuit 13 in the target sub-image Bγ, which can be expressed by the following formula:
[0081] addr = pre_addr + off2;
[0082] pre_addr is the memory address corresponding to the previous pixel obtained by the preprocessing circuit 13 in the corresponding target sub-image Bγ.
[0083] For pixel P0, since the preprocessing circuit 13 obtains the data of pixels P0 to P76 in sequence, pixel P0 will be the first pixel obtained by the preprocessing circuit 13 in the target sub-image B1 to which it belongs. In response to determining that pixel P0 is the first pixel obtained by the preprocessing circuit 13 in the target sub-image B1 to which it belongs, the preprocessing circuit 13 will calculate the first offset off1 as (FW-1)*FL according to the rotation angle of 90 degrees counterclockwise. Figure 3As shown, since the vertical length FW and the horizontal length FL of the target sub-image B1 to which the pixel P0 belongs are 7 and 4 respectively, the pre-processing circuit 13 can calculate the first offset off1 as 24 and initialize the count value AC corresponding to the target sub-image B1 to 0.
[0084] Please also read Figure 6 , Figure 6 FIG. 1 is a schematic diagram of calculating the memory address corresponding to a pixel in the target sub-image to which the present invention belongs. Figure 6 As shown, assuming that the starting memory address start_addr is X at this time, the preprocessing circuit 13 can also calculate that the memory address addr corresponding to the pixel P0 in the target sub-image B1 is X+24, and stores the data of the pixel P0 in the memory 14 according to the memory address addr being X+24.
[0085] Next, for pixel P1, since the x-axis coordinate value and y-axis coordinate value of pixel P1 in image Im also fall into the x-axis coordinate value range Rx1 and y-axis coordinate value range Ry1 of initial sub-image A1 in image Im, respectively, the pre-processing circuit 13 will also classify pixel P1 as belonging to the target sub-image B1 formed after the initial sub-image A1 is rotated by the rotation angle. In addition, since pixel P1 is not the first pixel obtained by the pre-processing circuit 13 in the target sub-image B1 to which it belongs, the pre-processing circuit 13 will calculate the second offset off2 as -FL=-4 based on the rotation angle of 90 degrees counterclockwise and the count value AC of the corresponding target sub-image B1 being 0, and at the same time add 1 to the count value AC of the corresponding target sub-image B1 (that is, the count value AC of the corresponding target sub-image B1 will be updated to 1 at this time).
[0086] The preprocessing circuit 13 also calculates the memory address addr corresponding to the pixel P1 in the target sub-image B1 to which it belongs, as X+24+(-4)=X+20 based on the second offset off2 and the memory address corresponding to the previous pixel (i.e., pixel P0) obtained by the preprocessing circuit 13 in the target sub-image B1 to which it belongs, and stores the data of the pixel P1 in the memory 14 according to the memory address addr being X+20.
[0087] Since the details of pixels P2 to P5 are the same as those in the previous content, they will not be repeated here. It is worth mentioning that Figure 2 As shown, the horizontal length and vertical length of the initial sub-image A2 can be 5 and 4 respectively, and according to the horizontal length, vertical length and position of the initial sub-image A2 in the image Im, the x-axis coordinate value range Rx2 and the y-axis coordinate value range Ry2 of the initial sub-image A2 in the image Im can be (11-5)≤Rx2≤(11-1) and 0≤Ry2≤(4-1), respectively.
[0088] For pixel P6, since the x-axis coordinate value and y-axis coordinate value of pixel P6 in image Im fall into the x-axis coordinate value range Rx1 and y-axis coordinate value range Ry1 of the initial sub-image A1 in image Im, respectively, and also fall into the x-axis coordinate value range Rx2 and y-axis coordinate value range Ry2 of the initial sub-image A2 in image Im, respectively, the pre-processing circuit 13 will classify pixel P6 as belonging to the target sub-image B2 in addition to the target sub-image B1.
[0089] In addition, the pre-processing circuit 13 performs a first address conversion procedure to calculate the memory address corresponding to the pixel P6 in the target sub-image B1 to which it belongs, and performs a second address conversion procedure to calculate the memory address corresponding to the pixel P6 in the target sub-image B2 to which it belongs.
[0090] During the process of executing the first address conversion program to calculate the memory address corresponding to the pixel P6 in the target sub-image B1 to which it belongs, in response to determining that the pixel P6 is not the first pixel obtained by the pre-processing circuit 13 in the target sub-image B1 to which it belongs, the pre-processing circuit 13 will calculate the second offset off2 as -FL=-4 based on the rotation angle of 90 degrees counterclockwise and the count value of the corresponding target sub-image B1 being 5, and at the same time increase the count value AC of the corresponding target sub-image B1 by 1 (that is, the count value AC of the corresponding target sub-image B1 will be updated to 6 at this time).
[0091] The preprocessing circuit 13 also calculates the memory address addr corresponding to the pixel P6 in the target sub-image B1 to which it belongs, as X+4+(-4)=X, based on the second offset off2 and the memory address corresponding to the previous pixel (i.e., pixel P5) obtained by the preprocessing circuit 13 in the target sub-image B1 to which it belongs, and stores the data of the pixel P6 in the memory 14 according to the memory address addr being X.
[0092] On the other hand, in the process of executing the second address conversion procedure to calculate the memory address corresponding to the pixel P6 in the target sub-image B2, in response to determining that the pixel P6 is the first pixel obtained by the pre-processing circuit 13 in the target sub-image B2, the pre-processing circuit 13 calculates the first offset off1 as (FW-1)*FL according to the rotation angle of 90 degrees counterclockwise, and initializes the count value AC corresponding to the target sub-image B2 to 0. Figure 3 As shown, since the vertical length FW and the horizontal length FL of the target sub-image B2 to which the pixel P6 belongs are 5 and 4 respectively, the pre-processing circuit 13 can calculate the first offset off1 to be 16 at this time.
[0093] like Figure 6As shown, assuming that the starting memory address start_addr is Y at this time, the pre-processing circuit 13 can calculate that the memory address addr corresponding to the pixel P6 in the target sub-image B2 is Y+16, and according to the memory address addr being Y+16, the data of the pixel P6 is also stored in the memory 14.
[0094] Next, for pixel P7, since the x-axis coordinate value and y-axis coordinate value of pixel P7 in image Im also fall into the x-axis coordinate value range Rx2 and y-axis coordinate value range Ry2 of initial sub-image A2 in image Im, respectively, the pre-processing circuit 13 will also classify pixel P7 as belonging to the target sub-image B2 formed after the initial sub-image A2 is rotated by the rotation angle. In addition, since pixel P7 is not the first pixel obtained by the pre-processing circuit 13 in the target sub-image B2 to which it belongs, the pre-processing circuit 13 will calculate the second offset off2 as -FL=-4 based on the rotation angle of 90 degrees counterclockwise and the count value AC of the corresponding target sub-image B2 being 0, and at the same time add 1 to the count value AC of the corresponding target sub-image B2 (that is, the count value AC of the corresponding target sub-image B2 will be updated to 1 at this time).
[0095] The preprocessing circuit 13 will also calculate the memory address addr corresponding to the pixel P7 in the target sub-image B2 to which it belongs based on the second offset off2 and the memory address corresponding to the previous pixel (i.e., pixel P6) obtained by the preprocessing circuit 13 in the target sub-image B2 to which it belongs, which is X+16+(-4)=X+12, and store the data of the pixel P7 in the memory 14 based on the memory address addr being X+12.
[0096] Since the details of the pixels P8 to P10 are the same as those in the previous content, they will not be described in detail here. It is worth mentioning that for the pixel P11, the pre-processing circuit 13 calculates the second offset off2 as FL*(FW-1)+1=25 according to the rotation angle of 90 degrees counterclockwise and the count value AC of the corresponding target sub-image B1 as 6, and initializes the count value AC of the corresponding target sub-image B1 to 0.
[0097] The preprocessing circuit 13 also calculates the memory address addr corresponding to the pixel P11 in the target sub-image B1 to which it belongs, as X+(25)=X+25, based on the second offset off2 and the memory address corresponding to the previous pixel (i.e., pixel P6) obtained by the preprocessing circuit 13 in the target sub-image B1 to which it belongs, and stores the data of the pixel P11 in the memory 14 according to the memory address addr being X+25.
[0098] Since the details of pixel P12 to pixel P39 are the same as the previous content, they will not be repeated here. It is worth mentioning that after the pixel data of the target sub-image B1 are stored in the memory 14, the pre-processing circuit 13 can set a flag corresponding to the target sub-image B1 to 1 to notify the neural network processing unit 15 to first extract the stored target sub-image B1 from the memory 14 for recognition. In this way, the pixel data of the target sub-image B3 can be stored in the area with memory addresses from X to X+27, thereby reducing the memory space required by the image recognition system 1, and the instructions and weight data required by the neural network processing unit 15 can also be stored in the area with memory addresses from X to X+27 to improve the performance of the neural network processing unit 15.
[0099] In this embodiment, the neural network image recognition system 1 may further include a first-in-first-out (FIFO) memory 12. The first-in-first-out memory 12 is coupled between the image sensor 11 and the pre-processing circuit 13, and is used to cache the data of the pixels P0 to P76. In other words, the pre-processing circuit 13 of this embodiment can obtain the data of the pixels P0 to P76 in sequence through the first-in-first-out memory 12, but the present invention is not limited thereto.
[0100] In summary, one of the beneficial effects of the present invention is that the neural network image recognition system and image preprocessing method provided by the present invention can simultaneously segment and rotate the image through the technical means of "classifying each pixel according to the segmentation specification and the rotation angle" and "calculating the corresponding memory address of each pixel in the target sub-image to which it belongs according to the rotation angle, and storing the pixel data in the memory according to the memory address", and store the segmented and rotated sub-images of the image in sequence in the memory, thereby reducing the required memory space.
[0101] The contents provided above are only preferred feasible embodiments of the present invention, and are not intended to limit the claims of the present invention. Therefore, all equivalent technical changes made using the contents of the present invention's specification and drawings are included in the claims of the present invention.
Claims
1. A neural network image recognition system, comprising: a memory; An image sensor is configured to obtain an image including a plurality of pixels, wherein the image is divided into a plurality of initial sub-images according to a segmentation specification, and the plurality of initial sub-images are rotated by a rotation angle to form a plurality of target sub-images; A pre-processing circuit is coupled to the image sensor and the memory and is configured to execute a pre-processing image procedure in the process of sequentially acquiring the data of the plurality of pixels, comprising the following steps: For each pixel, classify the pixel according to the segmentation specification and the rotation angle, so as to classify each pixel as belonging to at least one target sub-image; as well as For each pixel, a memory address corresponding to the pixel in the target sub-image to which the pixel belongs is calculated according to the rotation angle, and data of the pixel is stored in the memory according to the memory address, so as to store the plurality of target sub-images in the memory in sequence; as well as A neural network processing unit is coupled to the memory and configured to extract one of the stored target subgraphs from the memory for recognition. 2 . The image recognition system as claimed in claim 1 , wherein the segmentation specification defines a horizontal length, a vertical length and a position in the image for each initial sub-image.
3. An image recognition system as described in claim 2, wherein each pixel in the image has an x-axis coordinate value and a y-axis coordinate value, and the segmentation specification also defines an x-axis coordinate value range and a y-axis coordinate value range for each initial sub-image in the image.
4. An image recognition system as described in claim 3, wherein for each pixel, when the x-axis coordinate value and the y-axis coordinate value of the pixel in the image respectively fall into the x-axis coordinate value range and the y-axis coordinate value range of one of the initial sub-images in the image, the pre-processing circuit classifies the pixel as belonging to the target sub-image formed after the initial sub-image is rotated by the rotation angle.
5. The image recognition system as claimed in claim 1 , wherein the pre-processing circuit is configured to perform an address conversion procedure in the process of calculating the memory address corresponding to the pixel in the target sub-image according to the rotation angle, comprising the following steps: Determine whether the pixel is the first pixel obtained by the preprocessing circuit in the target sub-image to which the pixel belongs; In response to determining that the pixel is the first pixel obtained by the preprocessing circuit in the target sub-image, a first offset is calculated according to the rotation angle, a count value corresponding to the target sub-image is initialized to 0, and a memory address corresponding to the pixel in the target sub-image is calculated according to the first offset and a starting memory address; and In response to determining that the pixel is not the first pixel obtained by the preprocessing circuit in the target sub-image to which it belongs, a second offset is calculated based on the rotation angle and the count value corresponding to the target sub-image, and the memory address corresponding to the pixel in the target sub-image to which it belongs is calculated based on the second offset and the memory address corresponding to the previous pixel obtained by the preprocessing circuit in the target sub-image to which it belongs.
6. The image recognition system as claimed in claim 5, wherein the first offset is calculated according to the rotation angle by the following formula: Wherein off1 is the first offset, FW is a vertical length of the target sub-image to which the pixel belongs, FL is a horizontal length of the target sub-image to which the pixel belongs, and R is the rotation angle.
7. The image recognition system as claimed in claim 6, wherein the memory address corresponding to the pixel in the target sub-image to which it belongs is calculated according to the first offset and the starting memory address is represented by the following formula: addr = start_addr + off1; Wherein addr is the memory address corresponding to the pixel in the target sub-image to which it belongs, and start_addr is the starting memory address.
8. The image recognition system as claimed in claim 7, wherein the pre-processing circuit executes an algorithm to calculate the second offset according to the rotation angle and the count value corresponding to the target sub-image, and the algorithm is represented as follows: Wherein off2 is the second offset, and AC is the count value corresponding to the target sub-image.
9. A method for preprocessing an image, applicable to an image recognition system of a neural network, the image recognition system comprising a memory, an image sensor, a preprocessing circuit and a neural network processing unit, the image sensor being configured to obtain an image comprising a plurality of pixels, the image being divided into a plurality of initial sub-images according to a segmentation specification, and the plurality of initial sub-images being rotated by a rotation angle to form a plurality of target sub-images, wherein the preprocessing circuit being configured to execute the method for preprocessing an image in the process of sequentially obtaining data of the plurality of pixels, and the method for preprocessing an image comprising the following steps: For each pixel, classify the pixel according to the segmentation specification and the rotation angle, so as to classify each pixel as belonging to at least one target sub-image; as well as For each pixel, a memory address corresponding to the pixel in the target sub-image to which the pixel belongs is calculated according to the rotation angle, and data of the pixel is stored in the memory according to the memory address, so as to store the plurality of target sub-images in the memory in sequence; The neural network processing unit is coupled to the memory and is configured to extract one of the stored target subgraphs from the memory for recognition.
10. The image preprocessing method as claimed in claim 9, wherein the preprocessing circuit is configured to perform an address conversion procedure in the process of calculating the memory address corresponding to the pixel in the target sub-image according to the rotation angle, comprising the following steps: Determine whether the pixel is the first pixel obtained by the preprocessing circuit in the target sub-image to which the pixel belongs; In response to determining that the pixel is the first pixel obtained by the preprocessing circuit in the target sub-image, a first offset is calculated according to the rotation angle, a count value corresponding to the target sub-image is initialized to 0, and a memory address corresponding to the pixel in the target sub-image is calculated according to the first offset and a starting memory address; and In response to determining that the pixel is not the first pixel obtained by the preprocessing circuit in the target sub-image to which it belongs, a second offset is calculated based on the rotation angle and the count value corresponding to the target sub-image, and the memory address corresponding to the pixel in the target sub-image to which it belongs is calculated based on the second offset and the memory address corresponding to the previous pixel obtained by the preprocessing circuit in the target sub-image to which it belongs.