Image Processing Method, Apparatus, Terminal, and Readable Storage Medium
By determining the filtering area and overlapping area of the image block and acquiring and multiplexing image data, the problem of large amount of data in image processing is solved and the filtering processing efficiency is improved.
Patent Information
- Application Number
- CN202210126024.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-10
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-02-10
AI Technical Summary
In the process of image processing, the prior art requires a large amount of image data obtained for each image block, resulting in low filtering processing efficiency.
By determining the filtering area of the image block to be processed and the overlapping area of the adjacent image blocks, the image data of the adjacent image blocks is acquired and multiplexed, repeated reading is reduced, and filtering efficiency is improved.
The data volume read and write volume of filtering is reduced, and the filtering processing efficiency is improved.
Smart Images

Figure CN114519661B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image technology, and in particular, to an image processing method, an image processing apparatus, a terminal, and a non-volatile computer-readable storage medium. Background Art
[0002] Currently, when processing an image, the image is divided into blocks. When processing an image block, image data within a processing region corresponding to each image block is obtained, and generally, the processing region is larger than the region where the image block itself is located, so the amount of image data required for image processing is large. Summary of the Invention
[0003] Embodiments of this application provide an image processing method, an image processing apparatus, a terminal, and a non-volatile computer-readable storage medium.
[0004] The image processing method according to the embodiments of this application includes determining, according to the filtering radius of the current filtering layer, a filtering region for each to-be-processed image block in the to-be-processed image; obtaining an overlapping region between a first filtering region of the current to-be-processed image block and a second filtering region of a to-be-processed image block adjacent to the current to-be-processed image block; and obtaining first image data and second image data, where the first image data includes image data of a region outside the overlapping region in the first filtering region, and the second image data includes image data of the overlapping region, and the second image data is used for filtering by the adjacent to-be-processed image block.
[0005] The image processing apparatus according to the embodiments of this application includes a first determination module, a first obtaining module, and a second obtaining module. The first determination module is configured to determine, according to the filtering radius of the current filtering layer, a filtering region for each to-be-processed image block in the to-be-processed image; the first obtaining module is configured to obtain an overlapping region between a first filtering region of the current to-be-processed image block and a second filtering region of a to-be-processed image block adjacent to the current to-be-processed image block; and the second obtaining module is configured to obtain first image data and second image data, where the first image data includes image data of a region outside the overlapping region in the first filtering region, and the second image data includes image data of the overlapping region, and the second image data is used for filtering by the adjacent to-be-processed image block.
[0006] The terminal according to the embodiment of the present application includes a processor, and the processor is configured to determine, according to the filtering radius of the current filtering layer, the filtering area of each to-be-processed image block in the to-be-processed image; obtain the overlapping area between the first filtering area of the current to-be-processed image block and the second filtering area of the to-be-processed image block adjacent to the current to-be-processed image block; and obtain first image data and second image data, where the first image data includes the image data of the area outside the overlapping area in the first filtering area, and the second image data includes the image data of the overlapping area, and the second image data is used for filtering the adjacent to-be-processed image block.
[0007] A non-volatile computer-readable storage medium including a computer program according to the present application, when the computer program is executed by one or more processors, enables the processors to execute an image processing method. The image processing method includes determining, according to the filtering radius of the current filtering layer, the filtering area of each to-be-processed image block in the to-be-processed image; obtaining the overlapping area between the first filtering area of the current to-be-processed image block and the second filtering area of the to-be-processed image block adjacent to the current to-be-processed image block; and obtaining first image data and second image data, where the first image data includes the image data of the area outside the overlapping area in the first filtering area, and the second image data includes the image data of the overlapping area, and the second image data is used for filtering the adjacent to-be-processed image block.
[0008] For the image processing method, image processing device, terminal, and non-volatile computer-readable storage medium according to the embodiment of the present application, first, according to the filtering radius of the current filtering layer, the filtering area of the pre-segmented to-be-processed image blocks in the to-be-processed image is determined. The area of the filtering area is larger than that of the to-be-processed image block, and there is an overlapping area between the filtering areas of adjacent to-be-processed image blocks. Therefore, when filtering the current to-be-processed image block, the image data of the area outside the overlapping area in the first filtering area of the current to-be-processed image block (i.e., the first image data) and the image data of the overlapping area of the current to-be-processed image block (i.e., the second image data) are obtained. Since the second image data is the image data of the overlapping area between the first filtering area and the second filtering area of the adjacent to-be-processed image block, the second image data can be reused by the corresponding adjacent to-be-processed image block. Compared with each to-be-processed image block obtaining the image data of its corresponding filtering area and the second image data needing to be read twice, reusing the second image data of the current to-be-processed image block only requires reading the second image data once, thereby reducing the data read / write amount required for filtering processing and improving the filtering efficiency.
[0009] Additional aspects and advantages of the present application will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present application. Description of the Drawings
[0010] To more clearly illustrate the technical solutions in the embodiments of the present application or in the prior art, the following briefly introduces the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0011] Figure 1 is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0012] Figure 2 is a schematic block diagram of an image processing apparatus according to some embodiments of the present application;
[0013] Figure 3 is a schematic plan view of a terminal according to some embodiments of the present application;
[0014] Figures 4 to 7 is a schematic principle diagram according to some embodiments of the present application;
[0015] Figure 8 and Figure 9 is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0016] Figure 10 is a schematic principle diagram according to some embodiments of the present application;
[0017] Figure 11 and Figure 12 is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0018] Figure 13 Schematic connection diagram of a processor and a computer-readable storage medium according to some embodiments of the present application. Detailed Embodiments
[0019] The following further describes the embodiments of the present application with reference to the drawings. The same or similar reference numerals in the drawings represent the same or similar elements or elements having the same or similar functions throughout. Additionally, the embodiments of the present application described below with reference to the drawings are exemplary and are only used to explain the embodiments of the present application, and should not be construed as a limitation of the present application.
[0020] Please refer to Figures 1 to 3 , the image processing method of the embodiments of the present application includes the following steps:
[0021] 011: Determine the filtering region of each image block to be processed in the image to be processed according to the filtering radius of the current filtering layer;
[0022] 012: Obtain the overlapping region between the first filtering region of the current image block to be processed and the second filtering region of the image block to be processed adjacent to the current image block to be processed; and
[0023] 013: Obtain first image data and second image data. The first image data includes the image data of the region outside the overlapping region in the first filtering region, and the second image data includes the image data of the overlapping region. The second image data is used for filtering by adjacent image blocks to be processed.
[0024] The image processing apparatus 10 according to the embodiment of the present application includes a first determination module 11, a first acquisition module 12, and a second acquisition module 13. The first determination module 11, the first acquisition module 12, and the second acquisition module 13 are respectively used to execute step 011, step 012, and step 013. That is, the first determination module 11 is used to determine the filtering region of each image block to be processed in the image to be processed according to the filtering radius of the current filtering layer; the first acquisition module 12 is used to obtain the overlapping region between the first filtering region of the current image block to be processed and the second filtering region of the image block to be processed adjacent to the current image block to be processed; the second acquisition module 13 is used to obtain first image data and second image data. The first image data includes the image data of the region outside the overlapping region in the first filtering region, and the second image data includes the image data of the overlapping region. The second image data is used for filtering by adjacent image blocks to be processed.
[0025] The terminal 100 according to the embodiment of the present application includes a processor 30. The processor 30 is used to determine the filtering region of each image block to be processed in the image to be processed according to the filtering radius of the current filtering layer; obtain the overlapping region between the first filtering region of the current image block to be processed and the second filtering region of the image block to be processed adjacent to the current image block to be processed; and obtain first image data and second image data. The first image data includes the image data of the region outside the overlapping region in the first filtering region, and the second image data includes the image data of the overlapping region. The second image data is used for filtering by adjacent image blocks to be processed. That is to say, step 011, step 012, and step 013 can be implemented by the processor 30.
[0026] Specifically, the terminal 100 further includes a housing 40. The terminal 100 may be a mobile phone, a tablet computer, a display device, a laptop computer, a teller machine, a turnstile, a smart watch, a head-mounted device, a game console, etc. For example Figure 3As shown in the figure, the embodiment of the present application takes the terminal 100 as a mobile phone for illustration. It can be understood that the specific form of the terminal 100 is not limited to a mobile phone. The housing 40 can also be used to install functional modules such as a display device, an imaging device, a power supply device, and a communication device of the terminal 100, so that the housing 40 provides protection such as dust prevention, fall prevention, and water prevention for the functional modules.
[0027] The image to be processed can be an image captured by the camera 20 of the terminal 100, or an image downloaded from the Internet, which is not limited here. The image to be processed can also be a part of the image captured by the camera 20. The image to be processed can also be a depth image.
[0028] When filtering the image to be processed, it is generally carried out based on a preset filtering algorithm. The preset filtering algorithm can determine the preset size of the image to be processed, the preset number of filtering layers, and the filtering radius of each filtering layer.
[0029] The image to be processed includes a first edge, a second edge, a third edge, and a fourth edge. The first edge and the third edge are opposite, and the second edge and the fourth edge are opposite. The first edge can be the upper edge, and the second edge can be the left edge; or, the first edge can be the lower edge, and the second edge can be the right edge; or, the first edge can be the upper edge, and the second edge can be the right edge, etc. The following takes the first edge can be the upper edge and the second edge can be the left edge as an example for illustration.
[0030] When filtering, if the size of the image to be processed is larger than the preset size, the image to be processed can be divided into multiple image blocks to be processed through the preset size, so that the processor 30 can directly obtain the position information of each image block to be processed, such as the vertex coordinates of the image block to be processed (taking the image block to be processed as a rectangle as an example), and the position of the image block to be processed in the image to be processed (such as the image block to be processed is located on the left edge, the upper edge, and both on the left edge and the upper edge (i.e., the upper left corner)). At the same time, the processor 30 can also directly obtain the filtering radius of each filtering layer.
[0031] Then, the processor 30 can determine the filtering area of each image block to be processed according to the filtering radius of the current filtering layer. For example, the filtering radius is the distance from the edge of the image block to be processed. When determining the filtering area of each image block to be processed, it can be extended along the edge of the image block to be processed according to the filtering radius to determine the filtering area. Of course, in order to determine the position of the filtering area in the image to be processed, the position information of the image block to be processed (such as the vertex coordinates of the image block to be processed) and the filtering radius can be used to determine the filtering area.
[0032] Among them, the processor 30 can determine the vertex coordinates of the filtering area according to the vertex coordinates of the image block to be processed and the filtering radius. In an example, please refer to Figure 4, an image coordinate system is established with the upper left corner of the image block A1 to be processed as the origin. The width of the image block A1 to be processed is 8 (the number of pixels along the W direction), and the height is 8 (the number of pixels along the H direction). Then the vertex coordinates of the image block A1 to be processed are (0, 0), (8, 0), (0, 8), and (8, 8). If the filtering radius is 2 pixels, two rows of pixels are added to the upper and lower edges of the image block A1 to be processed respectively, and two columns of pixels are added to the left and right edges respectively. Then the vertex coordinates of the image block S1 to be processed are (-2, -2), (10, 2), (-2, 10), and (10, 10). In this way, according to the position information of the image block A1 to be processed and the filtering radius of each filtering layer, the image block S1 to be processed for each filtering layer can be quickly determined.
[0033] In other embodiments, the filtering radius includes a first filtering radius (such as the upper edge of the corresponding image), a second filtering radius (such as the right edge of the corresponding image), a third filtering radius (such as the lower edge of the corresponding image), and a fourth filtering radius (such as the left edge of the corresponding image). The first filtering radius, the second filtering radius, the third filtering radius, and the fourth filtering radius are all the same (such as Figure 4 the example shown); or the first filtering radius and the third filtering radius are the same, and the second filtering radius and the fourth filtering radius are the same; or, the first filtering radius, the second filtering radius, the third filtering radius, and the fourth filtering radius are all different.
[0034] In another example, please refer to Figure 5 , an image coordinate system is established with the upper left corner of the image block A1 to be processed as the origin. Then the vertex coordinates of the image block A1 to be processed are (0, 0), (8, 0), (0, 8), and (8, 8). If the first filtering radius and the third filtering radius are the same and both are 2 pixels, and the second filtering radius and the fourth filtering radius are the same and both are 1 pixel, then two rows of pixels are added to the upper and lower edges of the image block A1 to be processed respectively, and one column of pixels is added to the left and right edges respectively. Then the vertex coordinates of the image block S1 to be processed are (-1, -2), (9, -2), (-1, 10), and (9, 10). In this way, according to the position information of the image block A1 to be processed and the filtering radius of each filtering layer, the filtering region S1 for each filtering layer can be quickly determined.
[0035] In yet another example, please refer to Figure 6, taking the upper left corner of the image block A1 to be processed as the origin to establish an image coordinate system, the vertex coordinates of the image block A1 to be processed are respectively (0, 0), (8, 0), (0, 8) and (8, 8). If the first filtering radius, the second filtering radius, the third filtering radius and the fourth filtering radius are 4 pixels, 3 pixels, 2 pixels and 1 pixel respectively, then 4 rows of pixels and 2 rows of pixels are respectively added to the upper edge and the lower edge of the image block A1 to be processed, and 1 column of pixels and 3 columns of pixels are respectively added to the left edge and the right edge. Then the vertex coordinates of the image block S1 to be processed are respectively (-1, -4), (11, -4), (-1, 10) and (11, 10). In this way, according to the position information of the image block A1 to be processed and the filtering radius of each filtering layer, the image block S1 to be processed for each filtering layer can be quickly determined.
[0036] It can be understood that when performing filtering processing, it is necessary to obtain all the image data within the filtering area of each image block to be processed. Since the filtering area is larger than the area where the image block to be processed is located, when determining the filtering area of each image block to be processed, the overlapping area between the filtering areas of adjacent image blocks to be processed can be determined. Please refer to Figure 6 , for the adjacent image blocks A1 to be processed, there is an overlapping area C1 between their filtering areas S1. It should be noted that Figure 6 the squares in
[0037] are only used to illustrate pixels, but it is not limited that one square is only 1 pixel. In the existing technical solutions, for the image data within the overlapping area (i.e., the second image data), when performing filtering processing on two adjacent image blocks to be processed, in addition to each of the two image blocks to be processed needing to read the image data of the area outside the overlapping area (i.e., the first image data) from the memory 50 (such as the dynamic random access memory 50, DRAM) respectively, each also needs to read the second image data from the memory 50 of the terminal into the memory 60 (such as the tightly coupled memory (TCM) on the processing chip of the terminal 100 or the memory of the vision processing unit (VPU), etc.) once. That is, to perform filtering processing on the two image blocks to be processed, the second image data needs to be read twice from the memory 50, that is, the total amount of data to be read is 2 * (the first image data + the second image data). In this embodiment, after reading the second image data to perform filtering processing on the image block to be processed, the second image data can be stored in the first-level cache of the VPU, so as to facilitate the use of the second image data by adjacent unfiltered image blocks to be processed during filtering, and realize that the second image data can be read and written faster during reuse, improving the filtering efficiency and having lower power consumption.
[0038] It should be noted that the first image data of different image blocks to be processed can be different. The amount of data read here is only for illustration and cannot be limited to the first image data of two adjacent image blocks to be processed being the same.
[0039] After the present application determines the overlapping region of two adjacent image blocks to be processed, after obtaining the first image data and the second image data of the current image block to be processed, the second image data is reused for the image block to be processed that is adjacent to the current image block to be processed and has not been filtered. That is, only the second image data needs to be read from the memory 50 into the memory 60 once to implement the filtering process for two adjacent image blocks to be processed. The total amount of data that needs to be read is 2 * the first image data + the second image data. That is to say, by adopting the technical solution of the present application, one second image data reading can be reduced for every two adjacent image blocks to be processed, thereby reducing the amount of data read for the filtering process and improving the filtering efficiency.
[0040] In the current filtering layer, after completing the filtering process of an image block to be processed according to a preset filtering order (such as filtering the image blocks to be processed row by row from top to bottom, and when processing each row of image blocks to be processed, filtering them one by one from left to right), the processor 30 can store the second image data of the image block to be processed in the memory 60 for use in the filtering process of the image block to be processed that is adjacent to the image block to be processed and has not been filtered.
[0041] Specifically, a transfer memory can be separately set in the memory 60 (determine a part of the storage space in the first-level cache of the VPU as the transfer memory). After the current image block to be processed obtains the image data in the first filtering region, the second image data in the overlapping region of the first filtering region is stored in the transfer memory for use in the filtering process of the image block to be processed that is adjacent to the current image block to be processed. Thus, the image block to be processed that is adjacent to the current image block to be processed only needs to read the first image data outside the overlapping region in the second filtering region from the memory 50.
[0042] Among them, for the image data existing in the filtering region, it can be directly obtained (such as the part where the filtering region overlaps with the image to be processed), while for the part where there is no image data in the filtering region (the part where the filtering region does not overlap with the image to be processed), it needs to be filled according to the existing image data in the filtering region to obtain the image data of each pixel in the filtering region.
[0043] The image processing method, image processing apparatus 10, and terminal 100 according to the embodiments of the present application first determine, according to the filtering radius of the current filtering layer, the filtering region of the pre-segmented image block to be processed in the image to be processed. The area of the filtering region is larger than that of the image block to be processed, and there is an overlapping region between the filtering regions of adjacent image blocks to be processed. Therefore, when performing filtering processing on the current image block to be processed, the image data of the region outside the overlapping region in the first filtering region of the current image block to be processed (i.e., the first image data) and the image data of the overlapping region of the current image block to be processed (i.e., the second image data) are obtained. Since the second image data is the image data of the overlapping region between the first filtering region and the second filtering region of the adjacent image block to be processed, the second image data can be reused by the corresponding adjacent image block to be processed. Compared with each image block to be processed obtaining the image data of its corresponding filtering region and the second image data needing to be read twice, reusing the second image data of the current image block to be processed only requires reading the second image data once, thereby reducing the amount of data read and written required for filtering processing and improving the filtering efficiency.
[0044] Please refer to Figure 2 、 Figure 3 and Figure 7 , in some embodiments, the filtering layer includes multiple layers, and the image to be processed is sequentially filtered by the multiple filtering layers. The image processing method further includes:
[0045] 014: Determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the preset sub-filtering radius of the filtering layer after the current filtering layer.
[0046] In some embodiments, the image processing apparatus 10 further includes a second determination module 14. The second determination module 14 is used to execute step 014. That is, the second determination module 14 is used to determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the preset sub-filtering radius of the filtering layer after the current filtering layer.
[0047] In some embodiments, the processor 30 is further used to determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the preset sub-filtering radius of the filtering layer after the current filtering layer. That is to say, step 0121 and step 0122 can be implemented by the processor 30.
[0048] Specifically, the filtering layer includes multiple layers that sequentially process the image to be processed, such as 1, 2, 3, 4, 5, etc. Taking the filtering layer including 2 layers as an example, after the image data of the filtering region of the image block to be processed is sequentially processed by the first layer and the second layer, the filtering can be completed to generate a filtered image.
[0049] Each filtering layer has a preset sub-filtering radius. When determining the filtering radius of the current filtering layer, the processor 30 can determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the sub-filtering radii of the filtering layers after the current filtering layer.
[0050] For example, the filtering layer includes three layers. The sub-filtering radius of the first layer is r1, the sub-filtering radius of the second layer is r2, and the sub-filtering radius of the third layer is r3. The processor 30 can use the preset sub-filtering radius of the current filtering layer and the sum of the sub-filtering radii of all the filtering layers after the current filtering layer as the filtering radius of the current filtering layer, that is, the filtering radius of the current filtering layer = r1 + r2 + r3.
[0051] Please refer to Figure 2 、 Figure 3 and Figure 8 , in some embodiments, the image processing method further includes the following steps:
[0052] 015: Determine the output area of the filtering area of the current filtering layer according to the sub-filtering radius of the filtering layer after the current filtering layer.
[0053] 016 Determine the calculation area of the current to-be-processed image block according to the position information and output area of the current to-be-processed image block and the output areas of the to-be-processed image blocks that have completed filtering processing and are adjacent to the current to-be-processed image block.
[0054] 017: Re-determine the first filtering area of the current to-be-processed image block according to the sub-filtering radius of the current filtering layer and the calculation area.
[0055] Step 013 includes:
[0056] 0131: Obtain the image data corresponding to the re-determined first filtering area in the set composed of the first image data and the second image data.
[0057] In some embodiments, the image processing apparatus 10 further includes a third determination module 15, a fourth determination module 16, and a fifth determination module 17. The third determination module 15, the fourth determination module 16, the fifth determination module 17, and the second acquisition module 13 are respectively configured to execute step 015, step 016, step 017, and step 0131. That is, the third determination module 15 is configured to determine an output area of a filtering area of the current filtering layer according to a sub-filtering radius of a filtering layer after the current filtering layer; the fourth determination module 16 is configured to determine a calculation area of the current image block to be processed according to position information of the current image block to be processed, the output area, and output areas of the image blocks to be processed that are adjacent to the current image block to be processed and have completed filtering; the fifth determination module 17 is configured to re-determine a first filtering area of the current image block to be processed according to the sub-filtering radius of the current filtering layer and the calculation area; the second acquisition module 17 is configured to acquire image data corresponding to the re-determined first filtering area from a set composed of the first image data and the second image data.
[0058] In some embodiments, the processor 30 is further configured to determine an output area of a filtering area of the current filtering layer according to a sub-filtering radius of a filtering layer after the current filtering layer; determine a calculation area of the current image block to be processed according to position information of the current image block to be processed, the output area, and output areas of the image blocks to be processed that are adjacent to the current image block to be processed and have completed filtering; re-determine a first filtering area of the current image block to be processed according to the sub-filtering radius of the current filtering layer and the calculation area; and acquire image data corresponding to the re-determined first filtering area from a set composed of the first image data and the second image data. That is to say, step 015, step 016, step 017, and step 0131 can be implemented by the processor 30.
[0059] Specifically, the filtering radius of the current filtering layer is determined according to the sub-filtering radius of the current filtering layer and the sub-filtering radius of the filtering layer after the current filtering layer. Wherein, the sub-filtering radius of the current filtering layer is R1, and the sum of the sub-filtering radii of all the filtering layers after the current filtering layer is R2. After filtering is performed on the current filtering layer, the current filtering layer outputs filtering data of the area where the image block to be processed is located and filtering data of the area corresponding to R2, that is, the output area of the filtering area can be determined according to the image block to be processed and R2.
[0060] It can be understood, please refer to Figure 10, the dashed box represents the filtering area S1, and the dotted box represents the output area S2. There is an overlapping part C2 in the output areas S2 of adjacent image blocks A1 to be processed. In the prior art, after filtering two adjacent image blocks A1 to be processed, both of these two image blocks A1 to be processed will output the filtering data of the overlapping part C2, resulting in the need to perform filtering calculations twice for this overlapping part C2 and output it twice, reducing the efficiency of the filtering process.
[0061] When performing filtering, the filtering box is generally determined according to the sub-filtering radius of the current layer (such as R1), and is generally (2R1 + 1) * (2R1 + 1). Therefore, the image data used for filtering each pixel in this overlapping part is located within the overlapping area of the filtering areas of these two image blocks to be processed. Therefore, when filtering these two image blocks to be processed respectively, the image data within the filtering box when filtering each pixel in this overlapping part is the same. After filtering these two image blocks to be processed respectively, the filtering data within this overlapping part is also the same. Therefore, the filtering data within this overlapping part can be reused by these two image blocks to be processed.
[0062] After filtering one of these two image blocks to be processed, the filtering data of the overlapping part can be output. Therefore, when filtering the other of these two image blocks to be processed, it is not necessary to perform repeated filtering on the overlapping part, but only need to calculate the area outside the overlapping part in the output area of the image block to be processed.
[0063] Therefore, the processor 30 can determine the calculation area of the current image block to be processed according to the output area of the current image block to be processed and the output area of the image block to be processed adjacent to the current image block to be processed. Among them, the image block to be processed adjacent to the current image block to be processed needs to have been filtered to ensure that the current image block to be processed can reuse the filtering data of the overlapping part as the final output filtering data of the current image block to be processed.
[0064] For example, for the image block A1 to be processed, its width is TW and its height is TH. For Figure 10 After filtering the left image block A1 to be processed, the filtering data within the corresponding output area S2 of this image block A1 to be processed will be output. The width of the output area S2 is TW + 2 * R2, and the height is TH + 2 * R2. Among them, the width of the overlapping part C2 is 2 * R2, and the height is TH + 2 * R2. Therefore, the overlapping part C2 has a width offset of 2 * R2 relative to the corresponding output area S2 of the right image block A1 to be processed. Therefore, when determining the corresponding output area S2 of the right image block A1 to be processed, the calculation area S3 that needs to be calculated (such as Figure 10When in the filled part), according to the width offset of 2*R1, the calculation area S3 in the output area S2 corresponding to the to-be-processed image block A1 on the right can be quickly determined.
[0065] Of course, it can be understood that when the to-be-processed image cannot be divided into integer to-be-processed image blocks A1, there may be image blocks with sizes other than TW*TH. During processing, the overlapping area C1 for input multiplexing and the overlapping part C2 for output multiplexing can be accurately determined according to the actual width and length of adjacent to-be-processed image blocks A1, so as to ensure the accuracy of multiplexing.
[0066] Moreover, the positions of the to-be-processed image blocks A1 in the to-be-processed image are different, and the positions and quantities of the adjacent to-be-processed image blocks A1 that have not been filtered are also different. However, the principle of determining the calculation area is basically the same and will not be elaborated here.
[0067] In addition, when filtering all the to-be-processed image blocks of the to-be-processed image, it can be processed row by row according to the rows composed of the to-be-processed image blocks from left to right. For example, please refer to again Figure 7 , the to-be-processed image is divided into 9 to-be-processed image blocks, arranged in a 3*3 pattern. When performing filtering processing, the to-be-processed image block in the upper left corner can be processed first, and then the to-be-processed image blocks are processed to the right until the first row is processed, and then the leftmost side of the second row is processed for the second row. Of course, when filtering all the to-be-processed image blocks of the to-be-processed image, it can be processed column by column according to the columns composed of the to-be-processed image blocks from top to bottom, which is not limited here. In this embodiment, the case where all the to-be-processed image blocks of the to-be-processed image are filtered row by row according to the rows composed of the to-be-processed image blocks from left to right is taken as an example for illustration.
[0068] Therefore, the processor 30 can obtain the position information of the current to-be-processed image block to further determine the to-be-processed image blocks that have been filtered and are adjacent to the current to-be-processed image block, so as to realize the reuse of the filtered data in the overlapping part. For example, the position information includes at least one of the upper edge, left edge, and middle position of the to-be-processed image. When the current to-be-processed image block is in the upper left corner, it can be determined that the position information of the current to-be-processed image includes the upper edge and the left edge, that is, the current to-be-processed image is located at both the upper edge and the left edge; when the position information of the current to-be-processed image only includes the upper edge, that is, the current to-be-processed image is located at the upper edge but not at the left edge; when the position information of the current to-be-processed image only includes the left edge, that is, the current to-be-processed image is only located at the upper edge but not at the left edge; when the position information of the current to-be-processed image only includes the middle position, that is, the current to-be-processed image is not located at the upper edge or the left edge.
[0069] Therefore, when determining the calculation area, if the position information includes the upper edge, it means that there are adjacent image blocks to be processed on the left, right, and lower sides of the current image block to be processed. Since the filtering process of the image blocks to be processed is carried out row by row from left to right, only the image blocks to be processed on the left side of the current image block to be processed have been filtered. Therefore, the processor 30 can determine the calculation area based on the output area of the current image block to be processed and the output area of the image block to be processed adjacent to the left side of the current image block to be processed. For example, the area in the output area of the current image block to be processed that is outside the output area of the image block to be processed adjacent to the left side of the current image block to be processed is used as the calculation area.
[0070] If the position information includes the left edge, it means that there are adjacent image blocks to be processed on the upper, right, and lower sides of the current image block to be processed. Since the filtering process of the image blocks to be processed is carried out row by row from left to right, only the image blocks to be processed on the upper side of the current image block to be processed have been filtered. Therefore, the processor 30 can determine the calculation area based on the output area of the current image block to be processed and the output area of the image block to be processed adjacent to the upper side of the current image block to be processed. For example, the area in the output area of the current image block to be processed that is outside the output area of the image block to be processed adjacent to the upper side of the current image block to be processed is used as the calculation area.
[0071] If the position information includes the left edge and the upper edge, it means that the current image block to be processed is located at the upper left corner of the image to be processed. Therefore, the current image block to be processed is the first image block to be filtered, and there is no reusable filtering data for the current image block to be processed at this time. Therefore, the processor 30 directly uses the output area of the current image block to be processed as the calculation area.
[0072] If the position information includes the middle position, it means that there are adjacent image blocks to be processed on the upper, left, right, and lower sides of the current image block to be processed. Since the filtering process of the image blocks to be processed is carried out row by row from left to right, the image blocks to be processed on the upper and left sides of the current image block to be processed have been filtered. Therefore, the processor 30 can determine the calculation area based on the output area of the current image block to be processed and the output areas of the two image blocks to be processed adjacent to the upper and left sides of the current image block to be processed respectively. For example, the area in the output area of the current image block to be processed that is outside the output areas of the image blocks to be processed adjacent to the upper and left sides of the current image block to be processed is used as the calculation area.
[0073] Then, after determining the calculation area, according to the sub-filtering radius of the current filtering layer and the calculation area, the filtering area of the current image block to be processed can be re-determined. After filtering the re-determined filtering area, the filtering data of the calculation area can be output.
[0074] In this way, the calculation region of the adjacent unprocessed image block to be processed is determined by the output region of the processed image block to be processed, so that the filtered data of the overlapping part in the output region of the processed image block to be processed can be reused by the adjacent unprocessed image block to be processed. Only the calculation of the filtered data in the calculation region needs to be implemented, thereby reducing the calculation amount of the filtering process and improving the filtering efficiency.
[0075] Please refer to Figure 2 、 Figure 3 and Figure 11 In some embodiments, the filtering radius includes a fifth filtering radius and a sixth filtering radius, and the image processing method further includes the following steps:
[0076] 018: Filter the image data corresponding to the re-determined first filtering region to obtain first filtered data;
[0077] 019: According to the position information of the current image block to be processed, obtain second filtered data of the overlapping part that overlaps with the output region of the current image block in the output regions of the image blocks to be processed adjacent to the current image block to be processed;
[0078] 020: Output the filtered data of the output region of the current image block to be processed according to the first filtered data and the second filtered data.
[0079] In some embodiments, the image processing apparatus 10 further includes a filtering module 18, a third acquisition module 19, and an output module 20. The filtering module 18, the third acquisition module 19, and the output module 20 are respectively used to execute step 018, step 019, and step 020. That is, the filtering module 18 is used to filter the image data corresponding to the re-determined first filtering region to obtain first filtered data; the third acquisition module 19 is used to obtain, according to the position information of the current image block to be processed, second filtered data of the overlapping part that overlaps with the output region of the current image block in the output regions of the image blocks to be processed adjacent to the current image block to be processed; the output module 20 is used to output the filtered data of the output region of the current image block to be processed according to the first filtered data and the second filtered data.
[0080] In some embodiments, the processor 30 is further configured to perform filtering processing on the image data corresponding to the re-determined first filtering region to obtain first filtered data; according to the position information of the currently to-be-processed image block, obtain second filtered data of the overlapping part that overlaps with the output region of the currently to-be-processed image block in the output regions of the to-be-processed image blocks adjacent to the currently to-be-processed image block; and output the filtered data of the output region of the currently to-be-processed image block according to the first filtered data and the second filtered data. That is to say, step 018, step 019, and step 020 can be implemented by the processor 30.
[0081] Specifically, after filtering the currently to-be-processed image block, it is necessary to output the filtered data of the output region of the currently to-be-processed image block, where the output region includes the calculation region and the overlapping part of the output region of the currently to-be-processed image block and the output regions of the adjacent to-be-processed image blocks that have been filtered.
[0082] Therefore, after the processor 30 performs filtering processing on the re-determined filtering region, the first filtered data of the calculation region can be obtained. Then, the processor 30 directly obtains the second filtered data of the overlapping part of the adjacent to-be-processed image blocks that have been filtered with the currently to-be-processed image block, and thus the filtered data of the output region of the currently to-be-processed image block can be obtained. Here, the overlapping part of the adjacent to-be-processed image blocks that have been filtered with the currently to-be-processed image block refers to the overlapping part within the output region of the currently to-be-processed image block in the adjacent to-be-processed image blocks that have been filtered.
[0083] Finally, the processor 30 outputs the first image data and the second image data, which is to output the filtered data of the output region of the currently to-be-processed image block.
[0084] In other embodiments, after the currently to-be-processed image block completes filtering processing and outputs the filtered data of the output region of the currently to-be-processed image block, the to-be-processed image block adjacent to the currently to-be-processed image block but not yet filtered (hereinafter referred to as the target image block) can be determined according to the position information of the currently to-be-processed image block.
[0085] For example, the position information may include at least one of the upper edge, the left edge, and the middle position. Since the filtering processing order of the image block to be processed is preset (for example, the image block to be processed is filtered row by row from top to bottom, and when processing each row of the image block to be processed, filtering is performed one by one from left to right), therefore, according to the position information, it is possible to quickly determine which of the one or more image blocks to be processed adjacent to the current image block to be processed have been filtered and which have not been filtered. For example, if the position information includes the middle position, it can be determined that the two image blocks to be processed adjacent to the upper and left sides of the current image block to be processed have been filtered, and the two image blocks to be processed adjacent to the lower and right sides of the current image block to be processed have not been filtered.
[0086] Thereby, the filtered data of the overlapping part of the output area of the current image block to be processed and the output area of the target image block is stored in the transfer memory set in the memory 60, so that after the target image block is filtered, it can be used together with the filtered data of the calculation area of the target image block as the filtered data of the output area of the target image block, thereby realizing the reuse of the output data.
[0087] Please refer to Figure 2 、 Figure 3 and Figure 12 In some embodiments, the image processing method further includes:
[0088] 021: Re-determine the filtering radius according to the preset downsampling parameter, and perform filtering processing on the image block to be processed.
[0089] In some embodiments, the image processing apparatus 10 further includes a sixth determination module 21. The sixth determination module 21 is used to execute step 021. That is, the sixth determination module 21 is used to re-determine the filtering radius according to the preset downsampling parameter and perform filtering processing on the image block to be processed.
[0090] In some embodiments, the processor 30 is further used to re-determine the filtering radius according to the preset downsampling parameter and perform filtering processing on the image block to be processed. That is to say, step 021 can be implemented by the processor 30.
[0091] Specifically, when the image size of the image block to be processed is large, in order to further improve the filtering efficiency, the processor 30 can perform filtering processing according to the preset downsampling parameter. For example, it can process the pixels of the image block to be processed one by one at intervals of a predetermined number of pixels. For example, if the downsampling parameter is 1 / 2, it means that when performing filtering processing, the pixels of the image block to be processed can be processed one by one at intervals of 1 pixel, so that the number of pixels to be filtered is reduced to 1 / 2 of the original, reducing the amount of filtering processing.
[0092] Then, after the filtering of the image block to be processed is completed, the image block to be processed after filtering can be upsampled, so as to interpolate the pixels that have not been filtered according to the pixels that have been filtered in the image block to be processed after filtering, and quickly obtain the pixel values of the pixels that have not been filtered, while reducing the amount of filtering processing and ensuring the filtering effect.
[0093] Among them, in order to ensure that each pixel can be normally filtered when filtering according to the downsampling parameter, it is necessary to re-determine the filtering radius of the current filtering layer according to the downsampling parameter. For example, when the downsampling parameter is 1 / 2, the sub-filtering radius of the current filtering layer can be doubled. When the downsampling parameter is 1 / 3, the sub-filtering radius of the current filtering layer can be tripled, so as to re-determine the filtering radius of the current filtering layer. In this way, it can be ensured that each pixel can be normally filtered when filtering according to the downsampling parameter.
[0094] In other embodiments, when the size of the image to be processed is small and it is not easy to perform filtering processing, the image to be processed can also be only upsampled to improve the filtering effect. The processor 30 can re-determine the filtering radius according to the preset upsampling parameter and perform filtering processing on the image block to be processed.
[0095] For example, if the upsampling parameter is 2, it means that when performing filtering processing, each pixel can be collected twice, so that the number of pixels for filtering processing is increased to twice the original, thereby improving the filtering effect. In order to ensure that each pixel can be normally filtered when filtering according to the upsampling parameter, it is necessary to re-determine the filtering radius of the current filtering layer according to the upsampling parameter. For example, when the upsampling parameter is 2, the sub-filtering radius of the current filtering layer can be reduced by upsampling parameter / 2 + 1 (i.e., 2). When the upsampling parameter is 4, the sub-filtering radius of the current filtering layer can be reduced by upsampling parameter / 2 + 1 (i.e., 3), so as to re-determine the filtering radius of the current filtering layer. In this way, it can be ensured that each pixel can be normally filtered when filtering according to the upsampling parameter.
[0096] Please refer to Figure 13 , a non-volatile computer-readable storage medium 300 storing a computer program 302. When the computer program 302 is executed by one or more processors 30, the processor 30 can execute the image processing method of any of the above embodiments.
[0097] For example, please combine Figure 1 , when the computer program 302 is executed by one or more processors 30, the processor 30 performs the following steps:
[0098] 011: Determine the filtering region of each image block to be processed in the image to be processed according to the filtering radius of the current filtering layer.
[0099] 012: Obtain the overlapping region between the filtering regions of adjacent image blocks to be processed; and
[0100] 013: Obtain first image data and second image data. The first image data includes the image data of the region outside the overlapping region in the filtering region of the image block to be processed, and the second image data includes the image data of the overlapping region of the image block to be processed. Wherein, when performing filtering processing, two adjacent image blocks to be processed corresponding to the same overlapping region reuse the second image data.
[0101] For another example, please combine Figure 7 , when the computer program 302 is executed by one or more processors 30, the processor 30 may further perform the following steps:
[0102] 014: Determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the preset sub-filtering radius of the filtering layer after the current filtering layer.
[0103] In the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples", etc. mean that the specific features, structures, materials or characteristics described in connection with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0104] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment or part of the code of a program including one or more steps for implementing a specific logical function or process, and the scope of the preferred embodiments of the present application includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in the reverse order according to the involved functions, rather than in the order shown or discussed, which should be understood by those skilled in the art of the embodiments of the present application.
[0105] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.
Claims
1. An image processing method, characterized in that, Including: Determine the filtering region of each image block to be processed in the image to be processed according to the filtering radius of the current filtering layer, including: when determining the filtering region of each image block to be processed, expand along the edge of the image block to be processed according to the filtering radius to determine the filtering region; Obtain the overlapping region between the first filtering region of the current image block to be processed and the second filtering region of the image block to be processed adjacent to the current image block to be processed; and Obtain first image data and second image data, where the first image data includes the image data of the region outside the overlapping region in the first filtering region, and the second image data includes the image data of the overlapping region, and the second image data is used for filtering by the adjacent image block to be processed; The filtering layer includes multiple layers, and the image to be processed is sequentially filtered through multiple layers of the filtering layer. The image processing method further includes: Determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the preset sub-filtering radius of the filtering layer after the current filtering layer.
2. The image processing method according to claim 1, wherein Also including: Determine the output region of the filtering region of the current filtering layer according to the sub-filtering radius of the filtering layer after the current filtering layer; Determine the calculation region of the current image block to be processed according to the position information of the current image block to be processed, the output region, and the output regions of the image blocks to be processed adjacent to the current image block to be processed that have completed filtering; Redetermine the first filtering region according to the sub-filtering radius of the current filtering layer and the calculation region; The obtaining of the first image data and the second image data includes: Obtain the image data corresponding to the redetermined first filtering region in the set composed of the first image data and the second image data.
3. The image processing method according to claim 2, wherein The position information includes at least one of the first edge, the second edge, and the middle position of the image to be processed. The determining of the calculation region of the current image block to be processed according to the position information of the current image block to be processed, the output region, and the output regions of the image blocks to be processed adjacent to the current image block to be processed that have completed filtering includes: When the position information includes the first edge, determine the calculation region according to the output region of the current image block to be processed and the output region of the image block to be processed adjacent to the first edge of the current image block to be processed; When the position information includes the second edge, determine the calculation region according to the output region of the current image block to be processed and the output region of the image block to be processed adjacent to the second edge of the current image block to be processed; When the position information includes the first edge and the second edge, determine the calculation region according to the output region of the current image block to be processed; When the position information is the middle position, determine the calculation area according to the output area of the current image block to be processed and the output areas of two image blocks to be processed adjacent to the first edge and the second edge of the current image block to be processed respectively.
4. The image processing method according to claim 2, wherein Further included: Perform filtering on the image data corresponding to the re-determined first filtering area to obtain first filtered data; According to the position information of the current image block to be processed, obtain second filtered data of the overlapping part that overlaps with the output area of the current image block in the output areas of the image blocks to be processed that are adjacent to the current image block and have completed filtering; Output the filtered data of the output area of the current image block to be processed according to the first filtered data and the second filtered data.
5. The image processing method according to claim 1, wherein The filtering radius includes a first filtering radius, a second filtering radius, a third filtering radius, and a fourth filtering radius, and the first filtering radius, the second filtering radius, the third filtering radius, and the fourth filtering radius are all the same; or the first filtering radius and the third filtering radius are the same, and the second filtering radius and the fourth filtering radius are the same; or, the first filtering radius, the second filtering radius, the third filtering radius, and the fourth filtering radius are all different.
6. The image processing method according to claim 1, wherein Further included: After completing the filtering of the image block to be processed, store the second image data in the memory.
7. The image processing method according to claim 1, wherein Further included: Re-determine the filtering radius according to the preset downsampling parameters and perform filtering on the image block to be processed.
8. An image processing apparatus, characterized in that, Included: A first determination module, configured to determine the filtering area of each image block to be processed in the image to be processed according to the filtering radius of the current filtering layer, including: when determining the filtering area of each image block to be processed, expand along the edge of the image block to be processed according to the filtering radius to determine the filtering area; A first acquisition module, configured to acquire the overlapping area between the first filtering area of the current image block to be processed and the second filtering area of the image block to be processed adjacent to the current image block to be processed; and A second acquisition module, configured to acquire first image data and second image data, where the first image data includes the image data of the area outside the overlapping area in the first filtering area, and the second image data includes the image data of the overlapping area, and the second image data is used for filtering by the adjacent image block to be processed; The filtering layer includes multiple layers, and the image to be processed is sequentially filtered through multiple layers of the filtering layer; A second determination module, configured to determine the filtering radius of the current filtering layer according to the preset sub-filtering radius of the current filtering layer and the preset sub-filtering radius of the filtering layer after the current filtering layer.
9. A terminal, characterized in that, Including a processor, the processor is configured to determine, according to the filtering radius of the current filtering layer, a filtering region for each image block to be processed in the image to be processed, including: when determining the filtering region for each image block to be processed, expanding along the edge of the image block to be processed according to the filtering radius to determine the filtering region; obtaining an overlapping region between a first filtering region of the current image block to be processed and a second filtering region of an adjacent image block to be processed; and obtaining first image data and second image data, where the first image data includes image data of a region outside the overlapping region in the first filtering region, and the second image data includes image data of the overlapping region, and the second image data is used for filtering by the adjacent image block to be processed; the filtering layer includes multiple layers, and the image to be processed is sequentially filtered through multiple layers of the filtering layer, and the processor is further configured to determine the filtering radius of the current filtering layer according to a preset sub-filtering radius of the current filtering layer and a preset sub-filtering radius of the filtering layer after the current filtering layer.
10. A non-volatile computer-readable storage medium including a computer program, which, when executed by a processor, causes the processor to execute the image processing method according to any one of claims 1-7.
Citation Information
Patent Citations
Image consistency enhancing device
CN102968769A