An image processing method, apparatus, electronic device, and storage medium
By identifying and flipping the horizontally adjacent pixels at the center of the pixel matrix during image processing, and then performing algorithmic processing based on preset conditions, the problem of slow processing speed or excessive hardware resources in existing technologies is solved, thus achieving efficient image data processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-01
- Publication Date
- 2026-03-31
AI Technical Summary
Existing image processing methods are either too slow or require too much hardware resources, making them inefficient for processing image data.
The pixel to be processed is determined by identifying two horizontally adjacent pixels at the center of the pixel matrix. It is then judged whether the color meets the preset conditions. If it does not meet the preset conditions, it is horizontally mirrored and flipped. The processing is then performed according to the algorithm corresponding to the preset conditions, simplifying the hardware resource requirements.
Processing two pixels within a single clock cycle maintains high throughput, simplifies hardware resources, and improves image processing efficiency.
Smart Images

Figure CN114723620B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to an image processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] In digital image processing, image data output by image sensors is generally in RAW format. RAW format data cannot be used directly for display or other purposes; it must be processed by ISP (Image Signal Processing, which in this application may refer to an image processing chip or an image processing module within a chip) before it can be used for image display or other processing.
[0003] Existing technologies offer two different methods for data image processing:
[0004] The first method processes one pixel per clock cycle. Because it processes one pixel per clock cycle, the data throughput is low, resulting in slow data processing speed.
[0005] The second method processes two pixels per clock cycle. While this increases data throughput compared to the first method, it requires three separate processing algorithms for each pixel (red, green, or blue), along with corresponding color judgment and switching logic. This doubles the hardware resources required for implementation.
[0006] Therefore, existing image processing methods are either slow or require more hardware resources. Summary of the Invention
[0007] The purpose of this application is to solve one of the technical problems shown in the background art.
[0008] According to one aspect of the embodiments of this application, an image processing method is provided, the method comprising:
[0009] The two horizontally adjacent pixels at the center of the pixel matrix are identified as the pixels to be processed. If the color of the pixel to be processed does not meet the preset conditions, the positions of the two pixels are adjusted according to the preset horizontal mirror flip operation to obtain the updated pixel to be processed that meets the preset conditions. The updated pixel to be processed is then processed according to the algorithm corresponding to the preset conditions.
[0010] In one possible implementation, the two pixels are designated as the first pixel and the second pixel, respectively. Determining that the color of the pixel to be processed does not meet preset conditions includes:
[0011] If the preset condition is the first preset condition, when it is determined that the color of the first pixel is not green, it is determined that the color of the pixel to be processed does not meet the first preset condition. The first preset condition includes that, among two adjacent pixels, the color of the preceding pixel is green and the color of the following pixel is red or blue. Alternatively, if the preset condition is the second preset condition, when it is determined that the color of the second pixel is not green, it is determined that the color of the pixel to be processed does not meet the second preset condition. The second preset condition includes that, among two adjacent pixels, the color of the following pixel is green and the color of the preceding pixel is red or blue.
[0012] In another possible implementation, after determining the two horizontally adjacent pixels at the center of the pixel matrix as the pixels to be processed, the following is also included:
[0013] Obtain the Bayer arrangement pattern of the image frame to be processed, wherein the first pixel and the second pixel are derived from the image frame to be processed; determine the color of the first pixel based on the Bayer arrangement pattern and the row and column information of the first pixel in the image frame to be processed; determine the color of the second pixel based on the Bayer arrangement pattern and the row and column information of the second pixel in the image frame to be processed.
[0014] In another possible implementation, the positions of the two pixels are adjusted according to a preset horizontal mirror flip operation, including:
[0015] For each row of pixels in the pixel matrix, perform the following operations: determine all two mutually mirrored pixels in that row; swap the positions of all two mutually mirrored pixels.
[0016] In another possible implementation, if the pixel to be processed is determined to meet preset conditions, the method also includes:
[0017] If the preset condition is the first preset condition, when processing the second pixel, the first pixel is processed using the algorithm corresponding to green; if the preset condition is the second preset condition, when processing the first pixel, the second pixel is processed using the algorithm corresponding to green.
[0018] In another possible implementation, the updated pixels to be processed include the second pixel at the beginning and the first pixel at the end. The updated pixels to be processed are processed according to an algorithm corresponding to preset conditions, including:
[0019] If the preset condition is the first preset condition, when processing the first pixel, the second pixel is processed using the algorithm corresponding to green; if the preset condition is the second preset condition, when processing the second pixel, the first pixel is processed using the algorithm corresponding to green.
[0020] In yet another possible implementation, the method further includes:
[0021] Obtain the third and fourth pixel points obtained by the algorithm corresponding to the preset conditions, wherein the third and fourth pixel points are arranged sequentially in the horizontal direction; perform a horizontal mirror flip on the third and fourth pixel points to obtain the image processing result.
[0022] According to another aspect of the embodiments of this application, an image processing apparatus is provided, the apparatus comprising:
[0023] The first processing module is used to determine two horizontally adjacent pixels at the center of the pixel matrix as pixels to be processed; the second processing module is used to adjust the positions of the two pixels according to a preset horizontal mirror flip operation if the color corresponding to the pixel to be processed does not meet the preset conditions, so as to obtain an updated pixel to be processed that meets the preset conditions; the third processing module is used to process the updated pixel to be processed according to an algorithm corresponding to the preset conditions.
[0024] According to another aspect of the present application, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of an image processing method shown in one aspect of the present application.
[0025] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, wherein when the computer program is executed by a processor, it implements the steps of an image processing method shown in one aspect of this application.
[0026] The beneficial effects of the technical solutions provided in this application are:
[0027] This application provides an image processing method, specifically including: determining two horizontally adjacent pixels at the center of a pixel matrix as pixels to be processed; then, from a color perspective, determining whether the color corresponding to the pixel to be processed meets preset conditions; if not, horizontally mirroring the pixel to be processed; and processing the updated pixel to be processed according to an algorithm corresponding to the preset conditions. First, preset conditions and corresponding algorithms are set. Then, the pixels to be processed undergo preliminary processing (specifically, determining whether they meet the preset conditions; if not, horizontally mirroring is performed) to obtain pixels that meet the conditions. Finally, the pixel that meets the conditions is processed according to the algorithm corresponding to the preset conditions. Since processing two pixels per clock cycle maintains relatively high throughput, and processing updated pixels or pixels that meet the preset conditions using an algorithm corresponding to the preset conditions means that image processing can be performed using a reasonable amount of hardware resources, thereby simplifying hardware resources. The method shown in this embodiment ensures both processing speed and simplifies hardware resources, ultimately improving the efficiency of image processing. Attached Figure Description
[0028] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0029] Figure 1 This is a schematic diagram of the structure of RAW format data in the prior art;
[0030] Figures 2a-2d Here are structural diagrams of four Bayer arrangements in the existing technology;
[0031] Figure 2e This is a schematic diagram of the structure of an image frame to be processed, as disclosed in the prior art.
[0032] Figure 3 A schematic diagram of an image processing workflow based on ISP in the prior art;
[0033] Figure 4 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0034] Figure 5a A schematic diagram of a pixel matrix provided in an embodiment of this application;
[0035] Figure 5b A schematic diagram of a pixel matrix that has undergone horizontal mirroring and flipping processing, provided in an embodiment of this application;
[0036] Figure 6 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application;
[0037] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0038] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0039] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0041] First, let's introduce and explain several terms used in this application:
[0042] In the embodiments of this application, unless otherwise specified, R will be used to represent Red, G will be used to represent Green, and B will be used to represent Blue.
[0043] See Figure 1The prior art discloses a schematic diagram of RAW format data arrangement, in which each color block represents a pixel. Specifically, RAW format data refers to the raw data captured by an image sensor (e.g., an image sensor including a CMOS / CCD photosensitive array) and converted into digital signals. RAW format data cannot be directly used for display purposes; it generally needs to be processed by an ISP (Image Signal Processing, which in this embodiment generally refers to an image processing chip or an image processing module within a chip) to generate various image files suitable for display.
[0044] See Figures 2a-2d The existing Bayer arrangement uses 2x2 pixel blocks as a group, where each pixel is sequentially identified by the numbers 1, 2, 3, and 4. There are four possible color combinations for pixels 1, 2, 3, and 4: First, R1, G2, G3, B4 (Note: the colors of pixels 1 / 2 / 3 / 4 are red, green, green, and blue respectively; the explanations for the three combinations below can refer to the explanation for the first combination); Second, B1, G2, G3, R4; Third, G1, R2, B3, G4; Fourth, G1, B2, R3, G4. In the following embodiments, RGGB, BGGR, GRBG, and GBRG will be used to represent these four combinations. In this embodiment, the 2x2 pixel block in the upper left corner of the image frame to be processed only has these four possible arrangements.
[0045] Following the background technology, existing technologies disclose a process for determining data processing based on the number of pixels received by the ISP in each clock cycle, specifically Method 1 and Method 2.
[0046] The first approach involves receiving and processing one pixel per clock cycle. The pixel's color has three possibilities: red, blue, and green. Different processing algorithms are needed for each color, requiring corresponding hardware resources. In practice, after determining the pixel's color, the appropriate algorithm is switched for processing. However, processing only one pixel per clock cycle significantly reduces data processing speed, leading to lower data throughput. Ultimately, to minimize the amount of decision-making logic, three different hardware logic lines and corresponding processing algorithms need to be implemented.
[0047] The second method involves receiving and processing two pixels (specifically P1 and P2) each clock cycle. Based on the Bayer arrangement described above, P1 and P2 have only four possible configurations: R1, G2 (1 corresponds to P1, 2 corresponds to P2, indicating P1 is red and P2 is green; the other three configurations are explained similarly), B1, G2, G1, R2, and G1, B2. In the following embodiments, RG, BG, GR, and GB will be used to represent these four configurations. See also the examples below. Figure 2e The image frame to be processed is shown, where the color and coordinates of P1 are G(5,4) and the color and coordinates of P2 are B(5,5).
[0048] In actual processing, inputs P1 and P2 are processed in parallel. For point P1, there are three possibilities: R, G, and B, thus requiring the implementation of three processing algorithms; similarly, for point P2, there are also three possibilities: R, G, and B, requiring the implementation of three processing algorithms as well. While this method improves data throughput, it necessitates setting up three corresponding processing algorithms for each point, and furthermore, color judgment and switching of the appropriate color processing logic are required during actual processing. Ultimately, to minimize the amount of related logic, six different hardware logic lines and corresponding processing algorithms need to be implemented.
[0049] See Figure 3 The prior art discloses a schematic diagram of image processing based on an image sensor (ISP). The diagram includes an image sensor, an ISP module, and output results. When the image sensor transmits a frame of image (in RAW format) to the ISP, the data in that frame is transmitted to the ISP line by line from top to bottom in a pipeline manner. The ISP then processes the received data sequentially and finally outputs the processing result for that frame of image.
[0050] Existing image sensors, during image formation, cannot distinguish the wavelength of light (different wavelengths correspond to different colors) because the photosensitive array can only sense the intensity of light. Therefore, color filtering technology is needed to obtain the color information of pixels. Thus, the color of light is obtained by setting a CFA (color filter array, which filters light according to wavelength) in front of the photosensitive array, or by setting a CFA in the ISP. The most common CFA is the Bayer filter array, also known as the RGGB filter array, which allows red, blue, and green light to pass through. The intensity information of red, green, and blue light at a pixel is obtained through the Bayer filter, and then the color value of the pixel is calculated using a demosaicing algorithm.
[0051] Furthermore, in ISP, since processing rate-limiting points generally requires using surrounding pixels as reference information, a frame of image data needs to be buffered in rows and columns before processing. The buffered data can form an M*N pixel window (with the pixel to be processed located at the center of the window) before processing. Because there are four different Bayer arrangements, the color of the pixel to be processed at the center of the window has four possible color modes. If two pixels are processed simultaneously in one clock cycle, the color of the pixel needs to be determined at each step of the algorithm, and then the corresponding processing algorithm is called. In complex algorithms, this can significantly increase complexity. In RTL (register-transfer level, an abstraction level used to describe synchronous digital circuit operations) hardware implementations, the judgment and processing logic consumes more hardware resources. Since RTL hardware implementations are fixed once implemented, they are not modified.
[0052] This application provides an image processing method, apparatus, electronic device, and computer-readable storage medium, which aims to solve the above-mentioned technical problems of the prior art.
[0053] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0054] See Figure 4 This application provides a flowchart of an image processing method, which includes:
[0055] S410: Determine the two horizontally adjacent pixels at the center of the pixel matrix as the pixels to be processed.
[0056] Specifically, at the arrival of one clock cycle, an M x N pixel matrix from any frame of the image to be processed is received from the image sensor. Then, the horizontally adjacent pixels at the center of this pixel matrix are identified as the pixels to be processed. Here, M should be an odd number, and N should be an even number. The two horizontally adjacent pixels can include a first pixel and a second pixel arranged sequentially in the horizontal direction.
[0057] When determining the pixel matrix from any frame of the image to be processed, specifically, the pixel data is obtained by taking the pixel to be processed as the center and acquiring a total of M rows above and below the pixel to be processed, and a total of N columns to the left and right of the pixel to be processed. If the pixels to be processed are the two pixels in the upper left corner of any frame of the image, the pixels below can be flipped to the top and the pixels on the right can be flipped to the left, taking the two pixels in the upper left corner as the center, and finally obtaining a pixel matrix with a preset number of rows and preset columns. It should be noted that the method described above can be used to obtain the pixel matrix, or a custom method can be used, and this application embodiment does not limit this.
[0058] Again, refer to the example Figure 2e The image frame to be processed shown consists of 10*11 small squares, each representing a pixel. The content of each square can represent color and coordinates, for example, G(0,1), where "G" indicates the pixel's color is green, and "(0,1)" indicates the square's specific position in the image frame: in the first row and second column (in computer systems, rows and columns are identified starting from "0", with the first row and first column having coordinates of "0"). For example, if P1 is G(5,4) and P2 is B(5,5), then 9 rows and 10 columns of data are obtained centered on P1 and P2. This 9 rows * 10 columns data set can be a pixel matrix, which can be found in [reference needed]. Figure 5a .
[0059] S420: If it is determined that the color corresponding to the pixel to be processed does not meet the preset conditions, the positions of the two pixels are adjusted according to the preset horizontal mirror flip operation to obtain an updated pixel to be processed that meets the preset conditions.
[0060] Specifically, the preset condition can be a first preset condition or a second preset condition. The first preset condition can include: in two adjacent pixels, the preceding pixel is green and the following pixel is red or blue. The second preset condition can be: in two adjacent pixels, the following pixel is green and the preceding pixel is red or blue.
[0061] Specifically, determining that the color of the pixel to be processed does not meet the preset conditions may include: if the color of the first pixel is not green, determining that the color of the pixel to be processed does not meet the first preset condition; if the color of the second pixel is not green, determining that the color of the pixel to be processed does not meet the second preset condition.
[0062] The updated pixels to be processed include the second pixel that is in front and the first pixel that is in the back.
[0063] S430 updates the pixels to be processed according to an algorithm corresponding to preset conditions.
[0064] Specifically, the preset horizontal mirroring operation in S420 includes horizontally mirroring the pixel matrix to obtain an updated pixel matrix. Based on the updated pixel matrix, the updated pixels to be processed are processed according to an algorithm corresponding to preset conditions.
[0065] This application provides an image processing method, specifically including: determining two horizontally adjacent pixels at the center of a pixel matrix as pixels to be processed; then, from a color perspective, determining whether the color corresponding to the pixel to be processed meets preset conditions; if not, horizontally mirroring the pixel to be processed; and processing the updated pixel to be processed according to an algorithm corresponding to the preset conditions. First, preset conditions and corresponding algorithms are set. Then, the pixels to be processed undergo preliminary processing (specifically, determining whether they meet the preset conditions; if not, horizontally mirroring is performed) to obtain pixels that meet the conditions. Finally, the pixel that meets the conditions is processed according to the algorithm corresponding to the preset conditions. Since processing two pixels per clock cycle maintains relatively high throughput, and processing updated pixels or pixels that meet the preset conditions using an algorithm corresponding to the preset conditions means that image processing can be performed using a reasonable amount of hardware resources, thereby simplifying hardware resources. The method shown in this embodiment ensures both processing speed and simplifies hardware resources, ultimately improving the efficiency of image processing.
[0066] This application provides a possible implementation method. After determining the two horizontally adjacent pixels at the center of the pixel matrix as the pixels to be processed, the method may further include:
[0067] Obtain the Bayer arrangement pattern of the image frame to be processed, wherein the first pixel and the second pixel are derived from the image frame to be processed; determine the color of the first pixel based on the Bayer arrangement pattern and the row and column information of the first pixel in the image frame to be processed; determine the color of the second pixel based on the Bayer arrangement pattern and the row and column information of the second pixel in the image frame to be processed.
[0068] Specifically, Bayer permutation patterns include four types: RGGB, BGGR, GRBG, and GBRG, such as... Figures 2a to 2dAs shown, when there are two pixels to be processed, the colors of the two pixels can be one of four: RG, BG, GR, or GB. Since the pixel arrangement of the image frame follows a Bayer algorithm, the color information corresponding to the position of a pixel in each row is fixed. Therefore, after obtaining the Bayer algorithm of the image frame, the color of any given pixel can be determined based on its row and column information within the image frame.
[0069] This application embodiment also provides a possible implementation method, which adjusts the positions of two pixels according to a preset horizontal mirror flip operation, specifically including:
[0070] For each row of pixels in the pixel matrix, perform the following operations: determine all two mutually mirrored pixels in that row; swap the positions of all two mutually mirrored pixels.
[0071] See, for example Figure 5a and Figure 5b This pixel matrix can be a 9x10 matrix, with the first pixel being G(5,4) and the second pixel being B(5,5). Referring to Table 1, taking the pixels in the fifth row as an example, the pixels in the fifth row, from left to right, can be:
[0072]
[0073] The original 5th row of pixels in Table 1
[0074] Among them, G(5,0) and B(5,9), B(5,1) and G(5,8), G(5,2) and B(5,7), B(5,3) and G(5,6), and G(5,4) and B(5,5) are two mirror images of each other. After swapping their positions, the pixels in the 5th row from left to right are as follows:
[0075]
[0076] Table 2, new 5th row of pixels
[0077] This application embodiment also provides a possible implementation: if it is determined that the pixel to be processed meets a preset condition, the pixel to be processed is processed according to an algorithm corresponding to the preset condition. The processing of the pixel to be processed according to the algorithm corresponding to the preset condition may further include:
[0078] If the preset condition is the first preset condition, when processing the second pixel, the first pixel is processed using the algorithm corresponding to green; if the preset condition is the second preset condition, when processing the first pixel, the second pixel is processed using the algorithm corresponding to green.
[0079] In one possible implementation, the updated pixel to be processed is processed according to an algorithm corresponding to preset conditions, which may specifically include:
[0080] If the preset condition is the first preset condition, when processing the first pixel, the second pixel is processed using the algorithm corresponding to green, wherein the first pixel is a non-green pixel; if the preset condition is the second preset condition, when processing the second pixel, the first pixel is processed using the algorithm corresponding to green, wherein the second pixel is a non-green pixel.
[0081] Next, the analysis is based on the first preset condition: Two horizontally adjacent pixels are obtained from any Bayer arrangement. The colors of these two pixels can be R and G, or B and G, or G and R, or G and B, respectively. That is, when a pixel to be processed is obtained that includes two horizontally adjacent pixels, one of these pixels must be green. Therefore, the pixel at the beginning of the array is determined to be green. When processing this pixel, no judgment logic is needed; the processing algorithm corresponding to green can be directly applied. If the pixel at the beginning of the array is not green, the pixel to be processed can be horizontally flipped by mirroring the pixel matrix.
[0082] In one possible implementation, the process of handling non-green pixels may include:
[0083] If the preset condition is the first preset condition, the first pixel is processed using the algorithm corresponding to red or blue; if the preset condition is the second preset condition, the second pixel is processed using the algorithm corresponding to red or blue.
[0084] Specifically, when processing non-green pixels, since these non-green pixels are either red or blue, two processing algorithms can be used. In practice, color judgment is performed, and the corresponding color processing logic is switched accordingly.
[0085] When building RTL hardware based on the above method, only 3 different hardware logics and corresponding processing algorithms need to be implemented in the RTL hardware. Compared with the 6 different logics required by Method 2 in the prior art, it not only achieves parallel processing of 2 pixels in one clock cycle, but also simplifies hardware resources.
[0086] This application embodiment also provides a possible implementation method, in which, after processing the updated pixel points to be processed according to the algorithm corresponding to preset conditions, the method may further include:
[0087] Obtain the third and fourth pixel points obtained by the algorithm corresponding to the preset conditions, wherein the third and fourth pixel points are arranged sequentially in the horizontal direction; perform a horizontal mirror flip on the third and fourth pixel points to obtain the image processing result.
[0088] Specifically, after ISP processing, two horizontally arranged pixels are obtained, namely the third pixel and the fourth pixel. Since this processing targets the updated pixels to be processed, the second pixel is in front and the first pixel is behind. After obtaining the horizontally arranged third and fourth pixels, the third and fourth pixels are horizontally mirrored, resulting in the fourth pixel in front and the third pixel behind. This fourth pixel in front and the third pixel behind is the image processing result.
[0089] In one possible implementation, if the pixel to be processed is determined to meet the preset conditions, the pixel to be processed is processed according to the algorithm corresponding to the preset conditions to obtain the fifth and sixth pixels arranged horizontally in sequence, and these are used as the image processing result.
[0090] See Figure 6 This application also provides an image processing apparatus 600, which specifically may include:
[0091] The determining module 610 is used to determine two horizontally adjacent pixels at the center of the pixel matrix as pixels to be processed; the first processing module 620 is used to adjust the positions of the two pixels according to a preset horizontal mirror flip operation if the color corresponding to the determined pixel to be processed does not meet the preset conditions, so as to obtain an updated pixel to be processed that meets the preset conditions; the second processing module 630 is used to process the updated pixel to be processed according to an algorithm corresponding to the preset conditions.
[0092] In one possible implementation, the preset condition is either a first preset condition or a second preset condition, and the two pixels are, respectively, the first pixel and the second pixel. The first processing module 620, when determining that the pixel to be processed does not meet the preset condition, can specifically be used for:
[0093] If the preset condition is the first preset condition, when it is determined that the color of the first pixel is not green, it is determined that the color of the pixel to be processed does not meet the first preset condition. The first preset condition includes that, among two adjacent pixels, the color of the preceding pixel is green and the color of the following pixel is red or blue. If the preset condition is the second preset condition, when it is determined that the color of the second pixel is not green, it is determined that the color of the pixel to be processed does not meet the second preset condition. The second preset condition includes that, among two adjacent pixels, the color of the following pixel is green and the color of the preceding pixel is red or blue.
[0094] In one possible implementation, the device 600 further includes a third processing module 640, which, in particular, can be used for:
[0095] Obtain the Bayer arrangement pattern of the image frame to be processed, wherein the first pixel and the second pixel are derived from the image frame to be processed; determine the color of the first pixel based on the Bayer arrangement pattern and the row and column information of the first pixel in the image frame to be processed; determine the color of the second pixel based on the Bayer arrangement pattern and the row and column information of the second pixel in the image frame to be processed.
[0096] In one possible implementation, the first processing module 620, in adjusting the positions of two pixels according to a preset horizontal mirror flip operation, can specifically be used for:
[0097] For each row of pixels in the pixel matrix, perform the following operations: determine all two mutually mirrored pixels in that row; swap the positions of all two mutually mirrored pixels.
[0098] In one possible implementation, if it is determined that the pixel to be processed meets the preset conditions, the second processing module 630 can also be used for:
[0099] If the preset condition is the first preset condition, when processing the second pixel, the first pixel is processed using the algorithm corresponding to green; if the preset condition is the second preset condition, when processing the first pixel, the second pixel is processed using the algorithm corresponding to green.
[0100] In one possible implementation, the updated pixels to be processed include a second pixel at the beginning and a first pixel at the end. The second processing module 630, in processing the updated pixels according to an algorithm corresponding to preset conditions, can specifically be used for:
[0101] If the preset condition is the first preset condition, when processing the first pixel, the second pixel is processed using the algorithm corresponding to green; if the preset condition is the second preset condition, when processing the second pixel, the first pixel is processed using the algorithm corresponding to green.
[0102] In one possible implementation, the device 600 may further include a fourth processing module 650, which, after processing the updated pixels to be processed according to an algorithm corresponding to preset conditions, may specifically be used for:
[0103] Obtain the third and fourth pixel points obtained by the algorithm corresponding to the preset conditions, wherein the third and fourth pixel points are arranged sequentially in the horizontal direction; perform a horizontal mirror flip on the third and fourth pixel points to obtain the image processing result.
[0104] This application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of an image processing method shown in one aspect of this application.
[0105] In one alternative embodiment, an electronic device is provided, such as Figure 7 As shown, Figure 7 The illustrated electronic device 7000 includes a processor 7001 and a memory 7003. The processor 7001 and the memory 7003 are connected, for example, via a bus 7002. Optionally, the electronic device 7000 may further include a transceiver 7004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 7004 is not limited to one type, and the structure of the electronic device 7000 does not constitute a limitation on the embodiments of this application.
[0106] Processor 7001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 7001 may also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0107] Bus 7002 may include a pathway for transmitting information between the aforementioned components. Bus 7002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 7002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0108] The memory 7003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0109] The memory 7003 is used to store computer programs that execute the embodiments of this application, and its execution is controlled by the processor 7001. The processor 7001 is used to execute the computer programs stored in the memory 7003 to implement the steps shown in the foregoing method embodiments.
[0110] Among them, electronic devices include, but are not limited to, mobile terminals.
[0111] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.
[0112] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0113] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0114] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. An image processing method, characterized by, The method comprises: determining two horizontally adjacent pixels at the center of the pixel matrix as a pixel to be processed; obtaining a bayer arrangement mode of a to-be-processed image frame, wherein the first pixel and the second pixel are derived from the to-be-processed image frame; if it is determined that the color corresponding to the pixel to be processed does not meet a preset condition, adjusting the positions of the two pixels according to a preset horizontal mirror flipping operation to obtain an updated pixel to be processed that meets the preset condition; the two pixels are the first pixel and the second pixel in turn, and the determination that the color corresponding to the pixel to be processed does not meet the preset condition comprises: if the preset condition is a first preset condition, when it is determined that the color of the first pixel is not green, it is determined that the color corresponding to the pixel to be processed does not meet the first preset condition, wherein the first preset condition comprises that, among two adjacent pixels, the color of a preceding pixel is green, and the color of a following pixel is red or blue; or, if the preset condition is a second preset condition, when it is determined that the color of the second pixel is not green, it is determined that the color corresponding to the pixel to be processed does not meet the second preset condition, wherein the second preset condition comprises that, among two adjacent pixels, the color of a following pixel is green, and the color of a preceding pixel is red or blue; processing the updated pixel to be processed according to an algorithm corresponding to the preset condition; if it is determined that the pixel to be processed meets the preset condition, the method further comprises: if the preset condition is the first preset condition, when the second pixel is processed, the first pixel is processed by an algorithm corresponding to green; if the preset condition is the second preset condition, when the first pixel is processed, the second pixel is processed by an algorithm corresponding to green.
2. The method of claim 1, wherein, After determining two horizontally adjacent pixels at the center of the pixel matrix as a pixel to be processed, the method further comprises: determining the color of the first pixel according to the bayer arrangement mode and the row and column information of the first pixel in the to-be-processed image frame; determining the color of the second pixel according to the bayer arrangement mode and the row and column information of the second pixel in the to-be-processed image frame.
3. The method according to any of claims 1-2, characterized in that, The adjustment of the positions of the two pixels according to the preset horizontal mirror flipping operation comprises: for each row of pixels in the pixel matrix, the following operations are performed: determining all mutually mirror-image two pixels in the row; swapping the positions of all the mutually mirror-image two pixels.
4. The method of claim 1, wherein, The updated pixel to be processed comprises the second pixel in the front position and the first pixel in the rear position, and the processing of the updated pixel to be processed according to the algorithm corresponding to the preset condition comprises: if the preset condition is the first preset condition, when the first pixel is processed, the second pixel is processed by an algorithm corresponding to green; if the preset condition is the second preset condition, when the second pixel is processed, the first pixel is processed by an algorithm corresponding to green.
5. The method of claim 1, wherein, The method further comprises: obtaining a third pixel point and a fourth pixel point processed according to an algorithm corresponding to the preset condition, wherein the third pixel point and the fourth pixel point are arranged in sequence in a horizontal direction; performing horizontal mirror flipping on the third pixel point and the fourth pixel point to obtain an image processing result.
6. An image processing apparatus characterized by comprising: The device comprises: a determination module configured to determine two horizontally adjacent pixel points at the center of a pixel point matrix as to-be-processed pixel points; The device further comprises a third processing module configured to obtain a bayer arrangement mode of a to-be-processed image frame, wherein the first pixel point and the second pixel point are derived from the to-be-processed image frame; a first processing module configured to, if it is determined that the color corresponding to the to-be-processed pixel points does not meet a preset condition, adjust the positions of the two pixel points according to a preset horizontal mirror flipping operation to obtain updated to-be-processed pixel points meeting the preset condition; The two pixel points are the first pixel point and the second pixel point in sequence; The first processing module is further configured to determine that the color corresponding to the to-be-processed pixel points does not meet a preset condition in the following manner: If the preset condition is a first preset condition, it is determined that the color corresponding to the to-be-processed pixel points does not meet the first preset condition when it is determined that the color of the first pixel point is non-green, wherein the first preset condition comprises that, among two adjacent pixel points, the color of a preceding pixel point is green and the color of a following pixel point is red or blue; Or, If the preset condition is a second preset condition, it is determined that the color corresponding to the to-be-processed pixel points does not meet the second preset condition when it is determined that the color of the second pixel point is non-green, wherein the second preset condition comprises that, among two adjacent pixel points, the color of a following pixel point is green and the color of a preceding pixel point is red or blue; a second processing module configured to process the updated to-be-processed pixel points according to an algorithm corresponding to the preset condition; If it is determined that the to-be-processed pixel points meet the preset condition, the second processing module is further configured to, if the preset condition is the first preset condition, process the first pixel point by using an algorithm corresponding to green when processing the second pixel point; and if the preset condition is the second preset condition, process the second pixel point by using an algorithm corresponding to green when processing the first pixel point.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory, wherein the computer program comprises instructions that, when executed by the processor, cause the electronic device to perform the method of any one of claims 1-6. The processor executes the computer program to implement the steps of the method of any one of claims 1-5.
8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1-5.
Citation Information
Patent Citations
Picture processing method and device, computer equipment and storage medium
CN111739112A
Image processing method, processor, image processing device, program product and storage medium
CN114037606A
Color restoration method and device for Bayer image, equipment and storage medium
CN118297862A