Image quality adjusting method and system and medium

The method uses FPGA parallel processing and binary logic to efficiently reduce resource consumption and preserve image details in machine vision by optimizing middle value filtering, addressing the resource-intensity of existing methods.

CN120321520APending Publication Date: 2025-07-15HEFEI I TEK OPTOELECTRONICS CO LTD

Patent Information

Application Number
CN202411909985.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-07-15

AI Technical Summary

Technical Problem

The existing median filtering algorithms have a sharp increase in resource consumption when processing large window images, resulting in wasted hardware resources and poor edge pixel processing effect.

Method used

Using FPGA parallel processing technology, the pixel channel grayscale value is extracted in parallel by obtaining continuous image data, converting it into binary data, filtering median elements using binary and dichotomy methods, aggregating output in parallel, and processing edge pixels in combination with interpolation to reduce resource consumption and maintain image details.

Benefits of technology

It significantly reduces resource consumption, improves data processing efficiency, maintains image details of edge pixels, avoids edge blur, and achieves efficient image quality adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120321520A_ABST
    Figure CN120321520A_ABST
Patent Text Reader

Abstract

The invention discloses an image quality adjusting method and system and a medium. The adjusting method comprises the following steps: acquiring and converting binary data; based on the binary data corresponding to the gray value of each pixel channel, counting the number of all first elements and / or the number of second elements corresponding to each bit in sequence from high to low, so as to screen out elements with a large number as median elements corresponding to the current bit; wherein every time one median element is obtained through calculation, the other element, different from the corresponding median element, in all the elements corresponding to the current bit is assigned to the corresponding element of the subsequent bit; and counting the median elements corresponding to all the bits and aggregating and outputting from high to low to obtain a median. The method is realized on the basis of FPGA hardware, resource consumption is fully considered, the resource usage amount is reduced while low delay is considered on the basis of pipeline design, and a real-time and efficient implementation means is provided for large-window median filtering scene requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of machine vision, and in particular, relates to an image quality adjustment method, system and medium. Background Art

[0002] In order to improve image quality, various filtering algorithms are widely used in machine vision image processing. As an edge-preserving algorithm, median filtering plays a role in many scenarios. The core of the median filtering algorithm lies in finding the median value within an L×L (L = 3, 5, 7...) window. Based on high-data-rate scenarios in machine vision applications, it is usually necessary to process a single pixel point within a single clock cycle. Hardware generally adopts a pipeline-based implementation method to achieve higher throughput and faster processing speed. Median search methods are generally divided into two categories: one is the sorting method, such as bubble sort, selection sort, merge sort, odd-even transposition sort, quick sort, etc. These sorting-based methods arrange all the data within the window (for example, when L = 5, there are 25 data in total) in ascending or descending order, and select the data in the middle position as the output, which is the median; the other is the direct search method, that is, regardless of the size order of the entire set, the entire data set is divided into two subsets A / B, where the numbers in subset A are all less than or equal to R, and the data in subset B are all greater than or equal to R, then R is the median. From both the efficiency perspective and the hardware implementation perspective, the second type of method is more effective. In fact, no matter which type of method, as the window size increases, the resources consumed will increase sharply. For example, the resource consumption of the odd-even merge sort method in a 5×5 window is more than 5 times that in a 3×3 window. If the window size continues to increase to 7×7, the resource consumption is more than 15 times that in a 3×3 window.

[0003] In order to solve the problem of resource consumption, Chinese patent document CN118445550A discloses a median filtering method, device, storage medium and computer device, which determines the target median by accumulating and comparing the bit element results obtained by gradually dividing the binary data to be filtered, and realizes the calculation of the median based on the data storage width. However, after obtaining the target median step by step, it is necessary to count the third number and the fourth number. Among them, the third number is the number of remaining same-order bit elements in the previous-order bit elements except the target same-order bit element corresponding to this-order bit element, and the fourth number is the number of same-order bit elements in the current-order bit elements with the same category as the remaining same-order bit elements in the previous-order bit elements; and according to whether the sum of the third number and the fourth number is greater than the preset threshold to confirm the analysis of the target median of the next order, which additionally increases the resource consumption.

[0004] Therefore, in order to solve the above problems, the present invention provides an image quality adjustment method, system and medium. Summary of the Invention

[0005] The object of the present invention is to overcome the above problems existing in the prior art, and to provide an image quality adjustment method, system and medium.

[0006] To achieve the above technical object and reach the above technical effect, the present invention is realized through the following technical solutions: An image quality adjustment method, comprising: Based on FPGA, obtain the image data of several consecutive rows to be processed, and parallelly extract the gray values of each pixel channel within a rectangular array area with several identical pixel channels and an odd number, and respectively convert them into binary data; wherein, the binary data includes a first element and a second element; Based on the binary data corresponding to the gray values of each pixel channel, sequentially count the number of all first elements and / or second elements corresponding to each bit from high to low, so as to screen out the element with a larger number as the median element corresponding to the current bit; wherein, for each calculated median element, assign the other element different from the corresponding median element among all the elements corresponding to the current bit to the corresponding element of the subsequent bit; Count the median elements corresponding to all bits and aggregate and output them from high to low to obtain the median to replace the gray value of the pixel channel at the center position of the rectangular array area.

[0007] Further, for each calculated median element, perform an exclusive OR operation on all the elements corresponding to the current bit and the corresponding median element: If the operation result is zero, keep the corresponding binary data unchanged; If the operation result is one, assign the corresponding element of the subsequent bit of the corresponding binary data to the corresponding element of the current bit.

[0008] Further, if each pixel position of the image data of the row to be processed includes RGB three-channel data, respectively obtain the image data of several consecutive rows to be processed under each of the RGB channels, so as to independently calculate the median corresponding to all rectangular array areas under each of the RGB channels.

[0009] Further, it further includes: adding a row of interpolated row image data before the first row of image data to be processed and after the last row of image data to be processed, and adding an interpolated pixel at each of the beginning and end of all the image data of the row to be processed and the interpolated row image data.

[0010] Further, if the image data of the row to be processed is based on a Bayer array, that is, each pixel position of the image data of the row to be processed only contains R channel or G channel or B channel data, then extract the original row image data at intervals, and extract the gray values of each pixel channel in the original row image data at intervals, so as to form the image data of the row to be processed.

[0011] Further, it also includes: adding two interpolation line image data both before the first line of the to-be-processed line image data and after the last line of the to-be-processed line image data, and adding two interpolation pixels at both the head and the tail of all the to-be-processed line image data and the interpolation line image data.

[0012] Further, screening out the element with a larger quantity as the median element corresponding to the current bit includes: When the first element quantity and the second element quantity are simultaneously counted for the current bit, judge the magnitudes of the first element quantity and the second element quantity to screen out the element with a larger quantity as the median element corresponding to the current bit; When only the first element quantity or the second element quantity is counted for the current bit, if the first element quantity or the second element quantity is greater than the quantity parameter k, then use the corresponding element as the median element corresponding to the current bit, otherwise use the other element as the median element corresponding to the current bit.

[0013] Further, both the first element quantity and the second element quantity are counted using an adder.

[0014] The present invention also provides an image quality adjustment system, including: A data acquisition module, configured to obtain, based on an FPGA, the to-be-processed line image data of several consecutive lines, parallelly extract the gray values of each pixel channel within a rectangular array region with several identical pixel channels and an odd number of quantities, and respectively convert them into binary data; wherein, the binary data includes a first element and a second element; A data screening module, based on the binary data corresponding to the gray values of each pixel channel, is configured to sequentially count, from high to low, all the first element quantities and / or second element quantities corresponding to each bit to screen out the element with a larger quantity as the median element corresponding to the current bit; wherein, for each calculated median element, assign the other element different from the corresponding median element among all the elements corresponding to the current bit to the corresponding element of the subsequent bit; A data aggregation module, configured to count the median elements corresponding to all bits and aggregate and output them from high to low to obtain a median to replace the gray value of the pixel channel at the center position of the rectangular array region.

[0015] The present invention also provides a computer-readable storage medium, including a computer program, and when the computer program is executed by a processor, the above adjustment method is implemented.

[0016] The beneficial effects of the present invention are: (1) By acquiring the image data of several consecutive rows to be processed and performing parallel extraction based on FPGA, the parallel processing characteristics of FPGA are fully utilized, enabling multi-window parallel median filtering processing, which greatly improves the data processing efficiency. By collecting the gray values of each pixel channel in a rectangular array area with several identical pixel channels and an odd number, it can be applied to any scenario of single-channel or multi-channel, expanding its application range. By respectively converting them into binary data and sequentially counting the quantities of all first elements and / or second elements corresponding to each bit from high to low, the elements with larger quantities are selected as the median elements corresponding to the current bit, and combined with the final aggregated output. Compared with the traditional sorting method, it can significantly reduce the resource consumption. Even when facing the increase of the window size, it can still greatly reduce the resource consumption increment. By assigning the other element different from the corresponding median element among all elements corresponding to the current bit to the corresponding element of the subsequent bit, the characteristics of binary and dichotomy are fully combined, effectively reducing unnecessary data statistics and storage during the statistical process of the subsequent bits, thereby further reducing the resource consumption on the basis of binary.

[0017] (2) The resource consumption of the present invention is mainly affected by the data bit width, and the number of pipeline stages is determined by the data bit width. When the window size is large, on the one hand, the working clock frequency can be increased by continuing to insert pipelines, and on the other hand, the resource consumption is much lower than that of the traditional median search algorithm.

[0018] (3) The present invention is implemented based on FPGA hardware, fully considering resource consumption, and designed based on pipelines. While considering low latency, it reduces the resource usage, providing a real-time and efficient implementation means for the requirements of large-window median filtering scenarios.

[0019] (4) For the image data of rows to be processed from either true-color or pseudo-color cameras, through the edge pixel processing method of the present invention, when the edge pixels are subjected to median filtering processing, better image details can be retained, edge blurring can be avoided, the edge characteristics can be maintained, and the denoising effect can be further improved. Brief Description of the Drawings

[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings: Figure 1 is the flowchart of the adjustment method in the present invention; Figure 2 is the schematic diagram of the median element generation logic of each bit calculation unit in the present invention; Figure 3 is the schematic diagram of the new data generation logic in the present invention; Figure 4It is a schematic diagram of the R-channel data based on the true-color camera of the present invention; Figure 5 It is a schematic diagram of the principle of edge pixel interpolation of the present invention; Figure 6 It is a schematic diagram of the RGB three-channel distribution based on the pseudo-color camera of the present invention; Figure 7 It is a schematic diagram of the principle of edge pixel interpolation of the present invention; Figure 8 It is a schematic diagram of the R-channel distribution after edge interpolation of the present invention; Figure 9 It is a schematic diagram of one of the G-channel distributions after edge interpolation of the present invention; Figure 10 It is a schematic diagram of another G-channel distribution after edge interpolation of the present invention; Figure 11 It is a schematic diagram of the B-channel distribution after edge interpolation of the present invention; Figure 12 It is a block diagram of the search system structure of the present invention. Specific embodiments

[0021] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention. Embodiment 1

[0022] As Figure 1 shown, this embodiment first provides an image quality adjustment method, which specifically includes the following steps: Based on the FPGA, obtain the to-be-processed row image data of several consecutive rows, parallelly extract the gray values of each pixel channel in a rectangular array area with several identical pixel channels and an odd number, and respectively convert them into binary data; wherein, the binary data includes a first element and a second element.

[0023] By obtaining consecutive rows of image data to be processed, it is possible to provide more adjacent basic data for subsequent median search. The rectangular array area represents the median filter window, and the median search result of the median filter window corresponds to the filtered value of its central pixel position. An odd number means that both the number of rows and columns of the median filter window are odd, and the number of data in the window is N = 2k + 1. For example, N = 9 represents a 3×3 window size. In actual situations, the median filter window is also of odd sizes such as 3×3, 5×5, 7×7, etc., which is conducive to both determining the median value and maintaining the symmetry of the image. Whether dealing with multi-channel or single-channel image data to be processed, by collecting the pixel channel gray values of the same pixel channels, median filtering processing of each pixel position in the same channel can be achieved, which conforms to the actual usage scenarios of various cameras.

[0024] Based on FPGA, consecutive rows of image data to be processed are obtained, that is, the FPGA obtains consecutive rows of image data to be processed collected by the image sensor row by row, and parallelly extracts the gray values of each pixel channel in a rectangular array area with an odd number of the same pixel channels. This effectively combines the physical characteristics of FPGA parallel processing and can simultaneously perform synchronous processing on multiple median filter windows, as follows: Let the size of the median filter window be a × b , where a is the number of rows of the median filter window, which is odd, b is the number of columns of the median filter window, which is odd, and the number of FPGA channels is c ; When the a th row of image data to be processed is obtained, since the number of FPGA channels is c , it means that the FPGA can sample the data of c channels at the same time. Therefore, starting from the a th row of image data to be processed, every time c channels of data are obtained, c non-overlapping median filter windows can be processed simultaneously.

[0025] Among them, the first median filter window is: ; The c th median filter window is: ; Among them, p corresponds to the number of rows and q corresponds to the number of columns.

[0026] Then, in the next time period, the subsequent c non-overlapping median filter windows are completed. At this time, the first median filter window is: ; Thec The median filtering window is as follows: ; And so on until the median filtering of all median filtering windows in the first a rows is completed, and then continue to complete the first to a+1 rows in the above manner until the median filtering window covers the entire image.

[0027] As can be seen from the above, assuming that the current row number obtained by the FPGA is the u-th row, and let a constant array wind = (0, 1, 2, 3, 4, 5, 6, 7), then for the c median filtering window corresponding to the v-th time period of the current row number is as follows:

[0028] Taking an eight-channel FPGA as an example, assuming that the size of the median filtering window is 3×3 at this time, when the image data of the third row to be processed is obtained, for every 8 channels of data obtained, 8 non-overlapping median filtering windows can be processed simultaneously, that is, 8 median filtering windows of 3×3 are processed synchronously at the same time, and then the median filtering window is slid, and the subsequent 8 non-overlapping median filtering windows are completed in the next time period, and so on until the median filtering of all median filtering windows in the first three rows is completed, and then continue to complete the first to 4 rows in the above manner until the median filtering window covers the entire image, and the calculation results do not affect each other, so as to efficiently implement the median filtering of the image data of multiple rows to be processed. At the same time, the low-latency response and pipeline technology of the FPGA also provide performance advantages for the subsequent processing process based on binary data.

[0029] Based on the binary data corresponding to the gray values of each pixel channel, sequentially count the number of all first elements and / or second elements corresponding to each bit from high to low to select the element with a larger number as the median element corresponding to the current bit; among them, for each calculated median element, assign the other element different from the corresponding median element among all elements corresponding to the current bit to the corresponding element of the subsequent bit.

[0030] To efficiently search for the median, a method combining the binary method and binary is adopted. At this time, it is not based on the size of the data value itself, but based on the comparison method of bits (bit), and each data is represented in binary form, that is, marked by 1 and 0. The first element is 1, the second element is 0, and let the data bit width be W, then there is x j = [x j,w-1 x j,w-2 ...x j,1 x j,0], subscript j represents the sequence number of the current binary data, and subscript w-1 to 0 represents the sequence from the highest bit to the lowest bit, wherein selecting a larger number of elements as the median element corresponding to the current bit specifically includes the following steps: As a first implementation method of this step, if the current bit position simultaneously counts the number of first elements and the number of second elements, the size of the number of first elements and the number of second elements is determined to select the element with a larger number as the median element corresponding to the current bit position. Since the median element must be located among the elements with a larger number, the median element corresponding to the current bit position can be directly confirmed by comparing the number of first element 1s and the number of second element 0s.

[0031] As a second implementation of this step, if only the number of first elements or the number of second elements is counted for the current bit, if the number of first elements or the number of second elements is greater than the quantity parameter k, the corresponding element is used as the median element corresponding to the current bit, otherwise the other element is used as the median element corresponding to the current bit. Figure 2 The middle value element generation logic of each bit calculation unit is shown, starting from the highest bit x j,w-1 At the beginning, the number of the first element 1 in the highest bit position of all data is M. If M is greater than k, k=(N-1) / 2, then the median element corresponding to the highest bit position must also be 1, so the median element Y corresponding to the current bit position is output. i =1, otherwise output Y i =0, and the subscript i represents the sequence number corresponding to the current bit. Similarly, this method is used for each bit to obtain the median element corresponding to each bit.

[0032] Among them, every time a median element is calculated, all elements corresponding to the current bit are XORed with the corresponding median element: If the operation result is zero, the corresponding binary data remains unchanged; If the operation result is one, the corresponding element of the subsequent bit of the corresponding binary data is assigned to the corresponding element of the current bit.

[0033] Calculate the median element Y corresponding to the current bit i After that, according to the output Y i Value and the bit x of each data just participating in the statistics j,i Perform XOR operation to get SEL j,i , determine whether to adjust the corresponding binary data through the result of XOR operation, such as Figure 3 As shown in the figure, the working logic of the controller is as follows: a) When SEL j,i =0, then x j Keep the original value unchanged; b) When SEL j,i = 1, if x j,i = 1, Y i = 0: then x j = [x j,i-1 x j,i-2 ...x j,1 x j,0 = [1 1 … 1 1], that is, all the remaining bit positions are set to 1; c) When SEL j,i = 1, if x j,i = 0, Y i = 1: then x j = [x j,i-1 x j,i-2 ...x j,1 x j,0 = [0 0 … 0 0], that is, all the remaining bit positions are set to 0.

[0034] The purpose of this operation is to exclude all the data whose magnitudes have been compared, so as not to affect the subsequent statistical results. The principle here is to combine the logic of the binary search method on the basis of binary. Once it is confirmed that a certain data is less than the median, the data is incorporated into set A, and once it is confirmed that the data is greater than the median, the data is incorporated into set B. Setting the remaining value of the data to 0 or the maximum is for this purpose.

[0035] Finally, the median elements corresponding to all bit positions are statistically counted and aggregated and output from high to low to obtain the median to replace the grayscale value of the pixel channel at the center position of the rectangular array area. At this time, the median filtering process for the center pixel position of the current median filtering window is completed. Combining the parallel processing results of the FPGA, the final output result can be obtained by aggregating the median filtering processing results of all positions. By continuously sliding the median filtering window and calculating the corresponding median until the entire image is covered, the set of grayscale values of the pixel channels at the center positions of all rectangular array areas can be finally obtained, which is the denoised image.

[0036] As Figure 2 and Figure 3 shown, it is executed sequentially from the most significant bit (MSB) to the least significant bit (LSB). Thus, each bit is delayed by 2 cycles and the corresponding median element is output. After all the bit positions of all the data (starting from the MSB and ending at the LSB) are executed, the complete median Y = [Y w-1 ... Y i ... Y0] is output. Here, note that the output times of Y i are different, and the corresponding delay alignment needs to be performed on Y i before the final Y value is output.

[0037] It can be seen from this that after obtaining the median element corresponding to each bit in the present invention, the data whose size has been compared is directly modified, thereby avoiding subsequent influences, fully combining the logical characteristics of binary and dichotomy. Compared with the prior art CN118445550A, there is no need to count and calculate redundant variables. In particular, the present invention also combines the FPGA parallel processing technology. For the limited resource amount of the FPGA, the present invention only needs to perform one comparison for the current bit in each cycle to output the corresponding median element 1 or 0, without the need to perform the statistics and operations of the third number and the fourth number as in the prior art CN118445550A, effectively reducing the resource consumption, ensuring the data statistics accuracy of subsequent bits, and improving the operation efficiency. Embodiment 2

[0038] As a specific implementation manner of the present invention, if the to-be-processed row image data comes from a true-color camera, that is, each channel needs to be processed separately, as follows: If each pixel position of the to-be-processed row image data includes RGB three-channel data, the to-be-processed row image data of several consecutive rows under each of the RGB channels is respectively obtained, so as to independently calculate the median corresponding to all rectangular array regions under each of the RGB channels.

[0039] As Figure 4 shown, it is a schematic diagram of the R-channel data from a true-color camera. For the RGB three-channel data, separate calculations are performed, and the median filtering process is performed on the gray values of all pixel channels under each of the RGB channels by using the above adjustment method respectively, so as to respectively obtain all the data after filtering processing under each of the RGB channels.

[0040] As can be seen from the above, due to the size limitation of the median filter window, usually the minimum is 3×3, so the edge pixels of the image data cannot be effectively processed by the median filter. Therefore, to solve the edge optimization problem of all the to-be-processed row image data under each of the RGB channels, as follows: It further includes: adding a row of interpolation row image data before the first row of to-be-processed row image data and after the last row of to-be-processed row image data, and adding an interpolation pixel at the head and tail of all the to-be-processed row image data and the interpolation row image data.

[0041] Thus, the above method first adds two rows of interpolation row image data, and then adds an interpolation pixel at the head and tail, which is equivalent to adding a column of data at the head and tail, so that the edge pixel positions of all the to-be-processed row image data can achieve the median filtering process, providing an effective data operation basis.

[0042] As Figure 5As shown in the figure, to further ensure the denoising effect of the edge pixels of the image data, the following operations can be specifically performed: Insert the second row of the image data to be processed before the first row of the image data to be processed as the first interpolated row of image data, and insert the second-to-last row of the image data to be processed after the last row of the image data to be processed as the second interpolated row of image data. Then, insert the data corresponding to the second pixel position of the image data to be processed into the first position of this row as the first interpolated pixel, insert the data corresponding to the second-to-last pixel position of the image data to be processed into the last position of this row as the second interpolated pixel, insert the data corresponding to the second pixel position of the first interpolated row of image data and the second interpolated row of image data into the first position of this row as the third interpolated pixel, and insert the data corresponding to the second-to-last pixel position of the first interpolated row of image data and the second interpolated row of image data into the last position of this row as the fourth interpolated pixel. Thus, it is equivalent to adding two rows and two columns of supplementary data around the original image data to form a circle of new data, realizing the median filtering process for the edge pixel positions of the image data to be processed. For the image data to be processed from a true-color camera, through this method, better image details can be retained when median filtering is performed on the edge pixels, avoiding edge blurring and maintaining the edge characteristics. Embodiment 3

[0043] As a specific implementation manner of the present invention, if the image data to be processed comes from a pseudo-color camera, separate processing still needs to be performed on each channel, specifically as follows: If the image data to be processed is based on a Bayer array, such as the common RGGB distribution pattern, that is, each pixel position of the image data to be processed only contains data of the R channel, the G channel, or the B channel, then the original row image data is extracted at intervals, and the gray values of each pixel channel in the original row image data are extracted at intervals, thereby forming the image data to be processed.

[0044] As Figure 6 shown, it is a schematic diagram of the RGB three-channel distribution from a pseudo-color camera. Based on the RGGB layout pattern in the Bayer array, the G 12 and G 21 in the figure can be regarded as two different channels. Taking the R channel as an example, matrices of data composed of R 11 、R 13 、R 15 、R 17 、R 31 、R 33 、R 35 、R 37 etc. can be respectively extracted, and thus used as the image data to be processed. Then, median filtering processing is performed on the four channels respectively according to the adjustment method in Embodiment 1.

[0045] As can be seen from the above, for the same reason, there will still be edge pixels of the image data that cannot be effectively median-filtered in this embodiment. Therefore, to solve the edge optimization problem of all the to-be-processed row image data in each RGB channel, the following is specifically as follows: It further includes: adding two interpolation row image data before the first to-be-processed row image data and after the last to-be-processed row image data, and adding two interpolation pixels at the head and tail of all the to-be-processed row image data and the interpolation row image data respectively.

[0046] Thus, the above method first adds four interpolation row image data, and then by adding two interpolation pixels at the head and tail respectively, it is equivalent to adding two columns of data at the head and tail, so that the edge pixel positions of all the to-be-processed row image data can achieve median filtering processing, providing an effective data operation basis.

[0047] As Figure 7 shown, to further ensure the denoising effect of the edge pixels of the image data, the following operations can be specifically carried out: inserting the third to-be-processed row image data before the first to-be-processed row image data as the third interpolation row image data, and inserting the fourth to-be-processed row image data before the first to-be-processed row image data and after the third interpolation row image data as the fourth interpolation row image data; inserting the third-to-last to-be-processed row image data after the last to-be-processed row image data as the fifth interpolation row image data, and inserting the fourth-to-last to-be-processed row image data after the last to-be-processed row image data and before the fifth interpolation row image data as the sixth interpolation row image data.

[0048] Then insert the data corresponding to the third pixel position of the to-be-processed row image data into the first position of this row as the fifth interpolation pixel, insert the data corresponding to the fourth pixel position of the to-be-processed row image data into the second position of this row as the sixth interpolation pixel, insert the data corresponding to the third-to-last pixel position of the to-be-processed row image data into the last position of this row as the seventh interpolation pixel, and insert the data corresponding to the fourth-to-last pixel position of the to-be-processed row image data into the second-to-last position of this row as the eighth interpolation pixel; insert the data corresponding to the third pixel position of the third interpolation row image data to the sixth interpolation row image data into the first position of this row as the ninth interpolation pixel, insert the data corresponding to the fourth pixel position of the third interpolation row image data to the sixth interpolation row image data into the second position of this row as the tenth interpolation pixel, insert the data corresponding to the third-to-last pixel position of the third interpolation row image data to the sixth interpolation row image data into the last position of this row as the eleventh interpolation pixel, and insert the data corresponding to the fourth-to-last pixel position of the third interpolation row image data to the sixth interpolation row image data into the second-to-last position of this row as the twelfth interpolation pixel.

[0049] Thus, it is equivalent to adding a total of four rows and four columns of supplementary data around the original image data, forming two circles of new data, and implementing median filtering processing on the edge pixel positions of the row image data to be processed.

[0050] As Figure 8 shown, it is a schematic diagram of the R-channel distribution after edge interpolation. As Figure 9 shown, it is one of the schematic diagrams of the G-channel distribution after edge interpolation. As Figure 10 shown, it is another schematic diagram of the G-channel distribution after edge interpolation. As Figure 11 shown, it is a schematic diagram of the B-channel distribution after edge interpolation. Combining Figures 8 - 11 , the median filtering process can be performed on the four channels respectively according to the adjustment method in Embodiment 1. For the row image data to be processed from the pseudo-color camera, in this way, better image details can be retained when the edge pixels are subjected to median filtering, avoiding edge blurring and maintaining edge characteristics. Embodiment 4

[0051] As a specific implementation manner of the present invention, in order to better implement the statistics of the number of data, both the first element quantity and the second element quantity are statistically counted by an adder.

[0052] For example, for the statistics of the number of 1s in the N current highest bit positions, an N-bit adder can be used to implement it. The number of input bits of the adder is affected by the window size. For example, for a 3×3 window, the number of input bits is 9, and for a 7×7 window, the number of input bits is 49. Therefore, a pipeline stage is added to the adder output here to support a high clock frequency.

[0053] Thus, it can be seen that: As the median filtering window increases, without changing the data bit width, only N increases, that is, the input bit width of the adder increases, and the increase in adder resources is limited. Although the number of data to be cached also increases correspondingly with the increase in the amount of data N within the window, this is a necessary increase in resources, and other resources do not change significantly.

[0054] Thus, it can be seen that the increase in resource usage of this method as the window size increases is much less than that of other methods. Compared with the 3×3 window, the resource amount under the 5×5 window is about 1.5 times, and the resource amount under the 7×7 window is about 2 times, which is greatly reduced compared with 5 times / 15 times under the traditional median filtering method such as the odd-even merge sorting method. Embodiment 5

[0055] As Figure 12 shown, the second aspect of the present invention also provides an image quality adjustment system, including: A data acquisition module, which is used to obtain the to-be-processed line image data of several consecutive lines based on an FPGA, parallelly extract the gray values of each pixel channel within a rectangular array region with several identical pixel channels and an odd number of them, and convert them into binary data respectively; wherein, the binary data includes a first element and a second element.

[0056] A data screening module, based on the binary data corresponding to the gray values of each pixel channel, is used to sequentially count the quantities of all first elements and / or second elements corresponding to each bit from high to low, so as to screen out the element with a larger quantity as the median element corresponding to the current bit; wherein, for each calculated median element, the other element different from the corresponding median element among all elements corresponding to the current bit is assigned to the corresponding element of the subsequent bit.

[0057] A data aggregation module, which is used to count the median elements corresponding to all bits and aggregate and output them from high to low to obtain a median to replace the gray value of the pixel channel at the center position of the rectangular array region.

[0058] For the specific adjustment methods of the data acquisition module, the data screening module and the data aggregation module, reference can be made to Embodiments 1-3 for operation. Embodiment 6

[0059] The third aspect of the present invention further provides a computer-readable storage medium, including a computer program, and when the computer program is executed by a processor, the above adjustment method is implemented.

[0060] In practical applications, the computer-readable storage medium can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, apparatus or device, or any combination of the above. More specific examples of the computer-readable storage medium can include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus or device.

[0061] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.

[0062] The program code contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0063] The computer program code for performing the operations of the present application may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0064] In the description of this specification, the descriptions referring to terms such as "one embodiment", "example", "specific example", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. 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 may be combined in any one or more embodiments or examples in a suitable manner.

[0065] The above shows and describes the basic principles, main features, and advantages of the present invention. Those skilled in the art of this industry should understand that the present invention is not limited by the above embodiments. The above embodiments and the descriptions in the specification only illustrate the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention will have various changes and improvements, and all these changes and improvements fall within the scope of the present invention claimed.

Claims

1. An image quality adjustment method, characterized in that, Including: Based on FPGA, obtain the to-be-processed line image data of several consecutive lines, parallelly extract the gray values of each pixel channel within several rectangular array regions with the same number of pixel channels and an odd number, and convert them into binary data respectively; wherein, the binary data includes a first element and a second element; Based on the binary data corresponding to the gray values of each pixel channel, sequentially count the number of all first elements and / or second elements corresponding to each bit position from high to low to screen out the element with a larger number as the median element corresponding to the current bit position; wherein, for each calculated median element, assign the other element different from the corresponding median element among all elements corresponding to the current bit position to the corresponding element of the subsequent bit position; Count the median elements corresponding to all bit positions and aggregate and output them from high to low to obtain the median to replace the gray value of the pixel channel at the center position of the rectangular array region.

2. The image quality adjustment method according to claim 1, characterized in that For each calculated median element, perform an exclusive OR operation on all elements corresponding to the current bit position with the corresponding median element: If the operation result is zero, keep the corresponding binary data unchanged; If the operation result is one, assign the corresponding element of the subsequent bit position of the corresponding binary data to the corresponding element of the current bit position.

3. The image quality adjustment method according to claim 2, wherein If each pixel position of the to-be-processed line image data includes RGB three-channel data, obtain the to-be-processed line image data of several consecutive lines under each of the RGB channels respectively, so as to independently calculate the median corresponding to all rectangular array regions under each of the RGB channels.

4. The image quality adjustment method according to claim 3, characterized in that Also including: Add one line of interpolation line image data before the first line of to-be-processed line image data and after the last line of to-be-processed line image data, and add one interpolation pixel at the head and tail of all to-be-processed line image data and interpolation line image data.

5. The image quality adjustment method according to claim 2, characterized in that If the to-be-processed line image data is based on a Bayer array, that is, each pixel position of the to-be-processed line image data only contains R channel or G channel or B channel data, extract the original line image data at intervals, and extract the gray values of each pixel channel in the original line image data at intervals, so as to form the to-be-processed line image data.

6. The image quality adjustment method according to claim 5, wherein Also including: Add two lines of interpolation line image data before the first line of to-be-processed line image data and after the last line of to-be-processed line image data, and add two interpolation pixels at the head and tail of all to-be-processed line image data and interpolation line image data.

7. A method for adjusting image quality according to any one of claims 1-6, characterized in that Screening out the element with a larger number as the median element corresponding to the current bit position includes: When the number of first elements and the number of second elements are both statistically obtained at the current bit position, judge the size of the number of first elements and the number of second elements to screen out the element with a larger number as the median element corresponding to the current bit position; When only the number of first elements or the number of second elements is statistically obtained at the current bit position, if the number of first elements or the number of second elements is greater than the quantity parameter k, take the corresponding element as the median element corresponding to the current bit position, otherwise take the other element as the median element corresponding to the current bit position.

8. An image quality adjustment method according to claim 7, characterized in that, The number of first elements and the number of second elements are both statistically counted by an adder.

9. An image quality adjustment system, characterized in that, Including: A data acquisition module, based on FPGA, is used to acquire consecutive several rows of to-be-processed line image data, parallelly extract the gray values of each pixel channel in a rectangular array area with several same pixel channels and an odd number of them, and respectively convert them into binary data; wherein, the binary data includes a first element and a second element; A data screening module, based on the binary data corresponding to the gray values of each pixel channel, is used to sequentially count the quantities of all first elements and / or second elements corresponding to each bit position from high to low, so as to screen out the element with a larger quantity as the median element corresponding to the current bit position; wherein, for each calculated median element, the other element different from the corresponding median element among all elements corresponding to the current bit position is assigned to the corresponding element of the subsequent bit position; A data aggregation module is used to count the median elements corresponding to all bit positions and aggregate and output them from high to low to obtain a median to replace the gray value of the pixel channel at the center position of the rectangular array area.

10. A computer-readable storage medium, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the adjustment method described in any one of claims 1-8.

Citation Information

Patent Citations

  • Median filtering method and device, storage medium and computer equipment

    CN118445550A

Cited By

  • Median positioning method and system, electronic equipment and storage medium

    CN121934811A