[go: up one dir, main page]

CN116342394B - A FPGA-based real-time image demosaicing method, device and medium - Google Patents

A FPGA-based real-time image demosaicing method, device and medium Download PDF

Info

Publication number
CN116342394B
CN116342394B CN202310618823.XA CN202310618823A CN116342394B CN 116342394 B CN116342394 B CN 116342394B CN 202310618823 A CN202310618823 A CN 202310618823A CN 116342394 B CN116342394 B CN 116342394B
Authority
CN
China
Prior art keywords
channel
component
interpolated
matrix
interpolation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310618823.XA
Other languages
Chinese (zh)
Other versions
CN116342394A (en
Inventor
郝春玲
胡塘
王跃明
李相迪
闫力
王锡尔
任嵩楠
刘志威
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Lab
Original Assignee
Zhejiang Lab
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Lab filed Critical Zhejiang Lab
Priority to CN202310618823.XA priority Critical patent/CN116342394B/en
Publication of CN116342394A publication Critical patent/CN116342394A/en
Application granted granted Critical
Publication of CN116342394B publication Critical patent/CN116342394B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4015Image demosaicing, e.g. colour filter arrays [CFA] or Bayer patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4038Image mosaicing, e.g. composing plane images from plane sub-images
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Color Television Image Signal Generators (AREA)

Abstract

本发明公开了一种基于FPGA的实时图像去马赛克方法、装置和介质,该方法基于FPGA实现RAW域到RGB域的实时性转换,首先确定RAW域图像排列模式、图像分辨率大小、量化位宽、每个时钟输入像素点数和每个时钟输出像素点数;然后确定不同分量的插值模板;其次根据插值模板对图像进行行列流水线缓存获取待插值矩阵;再根据插值模板和待插值矩阵计算目标像素点缺失的通道分量;最后对插值结果进行转换处理输出。本发明采用流水线设计,处理延迟低,可利用像素间的相关信息提高插值质量,计算复杂度低,计算灵活,可灵活适配不同分辨率、不同量化位宽、不同RAW域排列模式、不同每个时钟输入像素点数和每个时钟输出像素点数的情况。

The invention discloses an FPGA-based real-time image demosaicing method, device and medium. The method realizes real-time conversion from the RAW domain to the RGB domain based on the FPGA. Firstly, the image arrangement mode, image resolution, and quantization bit width of the RAW domain are determined. , the number of pixels input by each clock and the number of pixels output by each clock; then determine the interpolation templates of different components; secondly, perform row-column pipeline buffering on the image according to the interpolation template to obtain the matrix to be interpolated; then calculate the target pixels according to the interpolation template and the matrix to be interpolated The missing channel component; finally, the interpolation result is converted and output. The present invention adopts a pipeline design, has low processing delay, can improve interpolation quality by using inter-pixel related information, has low computational complexity, flexible calculation, and can be flexibly adapted to different resolutions, different quantization bit widths, different RAW domain arrangement modes, and different The number of pixels input by each clock and the number of pixels output by each clock.

Description

一种基于FPGA的实时图像去马赛克方法、装置和介质A FPGA-based real-time image demosaicing method, device and medium

技术领域technical field

本发明涉及数字图像处理技术领域,尤其涉及一种基于FPGA的实时图像去马赛克方法、装置和介质。The present invention relates to the technical field of digital image processing, in particular to an FPGA-based real-time image demosaicing method, device and medium.

背景技术Background technique

数字彩色图像是人们获取媒体信息的主要通道之一,数字彩色图像每个像素点均由经过量化的K位位宽的红色(R)、绿色(G)、蓝色(B)组成,其中量化位宽K通常为8、10、12、16bit。但是由于工艺和成本的原因,目前市面上常见的彩色数码相机是单传感器数码相机,即通过一个图像传感器来捕捉彩色图像中每个像素的色彩信息。单传感器彩色数码相机中的图像传感器通常是感光耦合元件(Charge-coupled Device,CCD)或互补金属氧化物半导体(Complementary Metal Oxide Semiconductor,CMOS)芯片,而CCD和CMOS只能感受光的强度而非色彩,而彩色信息是通过滤色器阵列(Color Filter Array,CFA)获取的,通常后缀为.raw,因此也被称为RAW域图。从RAW域图像恢复RGB彩色图像的过程称为CFA插值(CFA Interpolation)或者去马赛克(Demosaicing)。去马赛克是整个相机图像处理中最前端,也是最关键的环节之一。Digital color image is one of the main channels for people to obtain media information. Each pixel of a digital color image is composed of quantized K-bit width red (R), green (G), and blue (B). The bit width K is usually 8, 10, 12, 16 bits. However, due to technical and cost reasons, the common color digital cameras currently on the market are single-sensor digital cameras, that is, an image sensor is used to capture the color information of each pixel in a color image. The image sensor in a single-sensor color digital camera is usually a photosensitive coupling device (Charge-coupled Device, CCD) or a complementary metal oxide semiconductor (Complementary Metal Oxide Semiconductor, CMOS) chip, while CCD and CMOS can only perceive the intensity of light instead of Color, and color information is obtained through a color filter array (Color Filter Array, CFA), usually with the suffix .raw, so it is also called a RAW domain map. The process of recovering an RGB color image from a RAW domain image is called CFA Interpolation or Demosaicing. Demosaicing is the most front-end and one of the most critical links in the entire camera image processing.

目前基于FPGA(Field Programmable Gate Arrays,可编程阵列逻辑)的去马赛克方法虽各有优势,但大多仅针对某一分辨率、某一量化位宽进行设计,其灵活性差,无法适配前端不同的输入图像。Although the current demosaic methods based on FPGA (Field Programmable Gate Arrays, programmable array logic) have their own advantages, most of them are only designed for a certain resolution and a certain quantization bit width, which has poor flexibility and cannot adapt to different front-end systems. Enter an image.

发明内容Contents of the invention

本发明的目的在于针对现有技术的不足,提供一种基于FPGA的实时图像去马赛克方法、装置和介质。The object of the present invention is to provide an FPGA-based real-time image demosaicing method, device and medium for the deficiencies of the prior art.

本发明的目的是通过以下技术方案来实现的:本发明实施例第一方面提供了一种基于FPGA的实时图像去马赛克方法,包括以下步骤:The object of the present invention is achieved through the following technical solutions: the first aspect of the embodiment of the present invention provides a real-time image demosaicing method based on FPGA, comprising the following steps:

(1)确定RAW域图像的排列模式、图像分辨率大小、量化位宽、每个时钟输入像素点数和每个时钟输出像素点数;(1) Determine the arrangement mode of the RAW domain image, image resolution, quantization bit width, number of input pixels per clock and output pixels per clock;

(2)确定不同分量的插值模板;(2) Determine the interpolation templates for different components;

(3)根据所述步骤(2)获取的插值模板对所述步骤(1)中的RAW域图像进行行列流水线缓存,以获取待插值矩阵和中心像素点的行计数和列计数;(3) performing row-column pipeline buffering on the RAW domain image in the step (1) according to the interpolation template obtained in the step (2), so as to obtain the row count and column count of the matrix to be interpolated and the central pixel;

(4)根据所述步骤(2)获取的插值模板和所述步骤(3)获取的待插值矩阵计算中心像素点缺失的通道分量;(4) Calculate the missing channel component of the central pixel according to the interpolation template obtained in step (2) and the matrix to be interpolated obtained in step (3);

(5)对所述步骤(4)获取的分量进行转换处理,并将中心像素点的R、G、B按顺序拼接。(5) Perform conversion processing on the components obtained in step (4), and stitch R, G, and B of the central pixel in order.

进一步地,所述排列模式包括RGGB、GRBG、BGGR和GBRG。Further, the arrangement mode includes RGGB, GRBG, BGGR and GBRG.

进一步地,所述每个时钟输出像素点数大于等于每个时钟输入像素点数。Further, the number of pixel points for each clock output is greater than or equal to the number of pixel points for each clock input.

进一步地,所述步骤(2)包括以下子步骤:Further, the step (2) includes the following sub-steps:

(2.1)确定R通道上的G分量插值模板;(2.1) Determine the G component interpolation template on the R channel;

(2.2)确定B通道上的G分量插值模板;(2.2) Determine the G component interpolation template on the B channel;

(2.3)确定Gr通道上的R分量插值模板;(2.3) Determine the R component interpolation template on the Gr channel;

(2.4)确定Gr通道上的B分量插值模板;(2.4) Determine the B component interpolation template on the Gr channel;

(2.5)确定Gb通道上的R分量插值模板;(2.5) Determine the R component interpolation template on the Gb channel;

(2.6)确定Gb通道上的B分量插值模板;(2.6) Determine the B component interpolation template on the Gb channel;

(2.7)确定R通道上的B分量插值模板;(2.7) Determine the B component interpolation template on the R channel;

(2.8)确定B通道上的R分量插值模板。(2.8) Determine the R component interpolation template on the B channel.

进一步地,所述步骤(3)包括以下子步骤:Further, the step (3) includes the following sub-steps:

(3.1)在原始数据后串联多个行缓存器;其中行缓存器的数量根据所述步骤(2)获取的插值模板的大小确定;(3.1) Multiple row buffers are connected in series behind the original data; the number of row buffers is determined according to the size of the interpolation template obtained in step (2);

(3.2)分别在每个行缓存器和原始数据后串联多个D触发器,以获取大小为M×(NPPC2+N-1)的待插值矩阵,并根据RAW域图像分辨率大小进行行列计数,以获取中心像素点的行计数和列计数;其中D触发器的数量根据所述步骤(1)中确定的RAW域图像的每个时钟输入像素点数和每个时钟输出像素点数以及所述步骤(2)获取的插值模板的大小确定。(3.2) Connect multiple D flip-flops in series after each row buffer and original data to obtain a matrix to be interpolated with a size of M×(NPPC2+N-1), and count rows and columns according to the resolution of the RAW domain image , to obtain the row count and column count of the central pixel; where the number of D flip-flops is determined according to the number of input pixels per clock and the number of output pixels per clock of the RAW domain image determined in the step (1) and the step (2) The size of the obtained interpolation template is determined.

进一步地,所述步骤(4)包括以下子步骤:Further, the step (4) includes the following sub-steps:

(4.1)对所述步骤(3)获取的大小为M×(NPPC2+N-1)的待插值矩阵进行拆分,以获取NPPC2个大小为M×N的待插值矩阵,其中NPPC2表示RAW域图像的每个时钟输出像素点数;(4.1) Split the matrix to be interpolated with a size of M×(NPPC2+N-1) obtained in step (3) to obtain 2 matrices to be interpolated with a size of M×N in NPPC, where NPPC2 represents the RAW domain The number of pixels output per clock of the image;

(4.2)根据所述步骤(3)获取的行计数和列计数并行确定NPPC2个待插值矩阵的中心像素点通道,是R通道、B通道、Gr通道、还是Gb通道;(4.2) According to the row count and column count obtained in the step (3), determine in parallel whether the central pixel channel of the NPPC2 matrices to be interpolated is the R channel, the B channel, the Gr channel, or the Gb channel;

(4.3)确定待插值矩阵是否包括边界位置像素,若待插值矩阵包括边界位置像素,则对待插值矩阵的缺失元素进行镜像映射;否则,直接进入步骤(4.4);(4.3) Determine whether the matrix to be interpolated includes pixels at boundary positions, and if the matrix to be interpolated includes pixels at boundary positions, perform mirror mapping on the missing elements of the matrix to be interpolated; otherwise, go directly to step (4.4);

(4.4)将待插值模板左移8位,以将待插值矩阵扩大256倍;(4.4) Shift the template to be interpolated to the left by 8 bits to expand the matrix to be interpolated by 256 times;

(4.5)根据每个待插值矩阵的中心像素点通道以及对应的待插值矩阵和插值模板并行NPPC2个插值计算模块计算中心像素点缺失的两个分量。(4.5) According to the central pixel point channel of each matrix to be interpolated and the corresponding matrix to be interpolated and the interpolation template, two parallel NPPC interpolation calculation modules are used to calculate the two missing components of the central pixel point.

进一步地,所述步骤(4.5)具体包括:若待插值矩阵的中心像素点通道为Gr通道,选取Gr通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取Gr通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为Gb通道,选取Gb通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取Gb通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为R通道,选取R通道上的G分量插值模板与待插值矩阵进行点乘以获取缺失的G分量,选取R通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为B通道,选取B通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取B通道上的G分量插值模板与待插值矩阵进行点乘以获取缺失的G分量。Further, the step (4.5) specifically includes: if the central pixel point channel of the matrix to be interpolated is the Gr channel, select the R component interpolation template on the Gr channel and perform point multiplication with the matrix to be interpolated to obtain the missing R component, and select Gr Do point multiplication of the B component interpolation template on the channel and the matrix to be interpolated to obtain the missing B component; if the center pixel channel of the matrix to be interpolated is the Gb channel, select the R component interpolation template on the Gb channel to perform point multiplication with the matrix to be interpolated To obtain the missing R component, select the B component interpolation template on the Gb channel and perform point multiplication with the matrix to be interpolated to obtain the missing B component; if the center pixel channel of the matrix to be interpolated is the R channel, select the G component on the R channel Perform point multiplication between the interpolation template and the matrix to be interpolated to obtain the missing G component, and select the B component interpolation template on the R channel to perform point multiplication with the matrix to be interpolated to obtain the missing B component; if the center pixel point channel of the matrix to be interpolated is B Channel, select the R component interpolation template on the B channel and perform point multiplication with the matrix to be interpolated to obtain the missing R component, select the G component interpolation template on the B channel and perform point multiplication with the matrix to be interpolated to obtain the missing G component.

进一步地,所述步骤(5)包括以下子步骤:Further, the step (5) includes the following sub-steps:

(5.1)将所述步骤(4)获取的分量缩小256倍;(5.1) The components obtained in the step (4) are reduced by 256 times;

(5.2)对缩小后的分量进行判定:若缩小后的分量小于0,则将其转换为0;若缩小后的分量大于,则将其转换为/>;若缩小后的分量小于等于/>且大于等于0,则不做转换,保持原值;其中K表示量化位宽;(5.2) Determine the reduced component: if the reduced component is less than 0, convert it to 0; if the reduced component is greater than , it is converted to /> ; If the reduced component is less than or equal to /> And greater than or equal to 0, no conversion will be performed and the original value will be kept; where K represents the quantization bit width;

(5.3)将NPPC2个中心像素点的R、G、B按顺序拼接后输出。(5.3) The R, G, and B of the 2 central pixels of NPPC are spliced in order and output.

本发明实施例第二方面提供了一种基于FPGA的实时图像去马赛克装置,包括一个或多个处理器,用于实现上述的基于FPGA的实时图像去马赛克方法。The second aspect of the embodiment of the present invention provides an FPGA-based real-time image demosaicing device, including one or more processors, configured to implement the above-mentioned FPGA-based real-time image demosaicing method.

本发明实施例第三方面提供了一种计算机可读存储介质,其上存储有程序,该程序被处理器执行时,用于实现上所述的基于FPGA的实时图像去马赛克方法。The third aspect of the embodiment of the present invention provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, it is used to implement the FPGA-based real-time image demosaicing method described above.

本发明的有益效果是,本发明采用流水线的设计方法,处理图像的延迟低;本发明可利用像素间的相关信息有效提高插值质量,计算复杂度低,计算灵活,可灵活适配不同分辨率、不同量化位宽、不同RAW域排列模式、不同每个时钟输入像素点数和每个时钟输出像素点数的情况,可以适配前端不同的输入图像。The beneficial effect of the present invention is that the present invention adopts the pipeline design method, and the delay of image processing is low; the present invention can effectively improve the interpolation quality by using the relevant information between pixels, the calculation complexity is low, the calculation is flexible, and different resolutions can be flexibly adapted , Different quantization bit widths, different RAW domain arrangement modes, different number of input pixels per clock and output pixels per clock, can adapt to different input images at the front end.

附图说明Description of drawings

图1是本发明的基于FPGA的实时图像去马赛克方法的流程图;Fig. 1 is the flowchart of the FPGA-based real-time image demosaicing method of the present invention;

图2是本发明的RAW域图像的RGGB排列模式示意图;Fig. 2 is a schematic diagram of the RGGB arrangement mode of the RAW domain image of the present invention;

图3是本发明的RAW域图像的GRBG排列模式示意图;Fig. 3 is a schematic diagram of the GRBG arrangement mode of the RAW domain image of the present invention;

图4是本发明的RAW域图像的BGGR排列模式示意图;Fig. 4 is a schematic diagram of the BGGR arrangement mode of the RAW domain image of the present invention;

图5是本发明的RAW域图像的GBRG排列模式示意图;Fig. 5 is a schematic diagram of the GBRG arrangement mode of the RAW domain image of the present invention;

图6是本发明的GRBG排列模式下采用双线性插值法确定的Gr通道上的B分量和Gb通道上的R分量插值模板示意图;Fig. 6 is a schematic diagram of the B component on the Gr channel and the R component interpolation template on the Gb channel determined by the bilinear interpolation method under the GRBG arrangement mode of the present invention;

图7是本发明的GRBG排列模式下采用双线性插值法确定的Gr通道上的R分量和Gb通道上的B分量插值模板示意图;Fig. 7 is a schematic diagram of the R component on the Gr channel and the B component interpolation template on the Gb channel determined by the bilinear interpolation method under the GRBG arrangement mode of the present invention;

图8是本发明的GRBG排列模式下采用双线性插值法确定的R通道上的B分量和B通道上的R分量插值模板示意图;Fig. 8 is a schematic diagram of the B component on the R channel and the R component interpolation template on the B channel determined by the bilinear interpolation method under the GRBG arrangement mode of the present invention;

图9是本发明的GRBG排列模式下采用双线性插值法确定的R通道上的G分量和B通道上的G分量插值模板示意图;Fig. 9 is a schematic diagram of the G component on the R channel and the G component interpolation template on the B channel determined by bilinear interpolation in the GRBG arrangement mode of the present invention;

图10是本发明的GRBG排列模式下采用HQLI法确定的Gr通道上的B分量和Gb通道上的R分量插值模板示意图;Fig. 10 is a schematic diagram of the B component on the Gr channel and the R component interpolation template on the Gb channel determined by the HQLI method in the GRBG arrangement mode of the present invention;

图11是本发明的GRBG排列模式下采用HQLI法确定的Gr通道上的R分量和Gb通道上的B分量插值模板示意图;11 is a schematic diagram of the R component on the Gr channel and the B component interpolation template on the Gb channel determined by the HQLI method in the GRBG arrangement mode of the present invention;

图12是本发明的GRBG排列模式下采用HQLI法确定的R通道上的G分量和B通道上的G分量插值模板示意图;Fig. 12 is a schematic diagram of the G component on the R channel and the G component interpolation template on the B channel determined by the HQLI method under the GRBG arrangement mode of the present invention;

图13是本发明的GRBG排列模式下采用HQLI法确定的R通道上的B分量和B通道上的R分量插值模板示意图;Fig. 13 is a schematic diagram of the B component on the R channel and the R component interpolation template on the B channel determined by the HQLI method under the GRBG arrangement mode of the present invention;

图14是本发明的待插值矩阵的获取方法流程图;Fig. 14 is a flowchart of a method for obtaining a matrix to be interpolated in the present invention;

图15是本发明的GRBG排列模式下图像右下角像素点的待插值矩阵映射图;Fig. 15 is a matrix map to be interpolated for pixels in the lower right corner of the image under the GRBG arrangement mode of the present invention;

图16是本发明的GRBG排列模式下图像左上角像素点的待插值矩阵映射图;Fig. 16 is a matrix map to be interpolated for pixels in the upper left corner of the image under the GRBG arrangement mode of the present invention;

图17是本发明的大小为M×(N+NPPC2-1)的待插值矩阵分解为NPPC2个M×N待插值矩阵的示意图;Fig. 17 is a schematic diagram of decomposing the matrix to be interpolated into NPPC2 M×N matrices to be interpolated with a size of M×(N+NPPC2-1) according to the present invention;

图18是本发明的基于FPGA的实时图像去马赛克装置的一种结构示意图。FIG. 18 is a schematic structural diagram of an FPGA-based real-time image demosaicing device of the present invention.

具体实施方式Detailed ways

这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本发明相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本发明的一些方面相一致的装置和方法的例子。Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with aspects of the invention as recited in the appended claims.

在本发明使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本发明。在本发明和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terminology used in the present invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used herein and in the appended claims, the singular forms "a", "the", and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It should also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

应当理解,尽管在本发明可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本发明范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of the present invention, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word "if" as used herein may be interpreted as "at" or "when" or "in response to a determination."

下面结合附图,对本发明进行详细说明。在不冲突的情况下,下述的实施例及实施方式中的特征可以相互组合。The present invention will be described in detail below in conjunction with the accompanying drawings. If there is no conflict, the features in the following embodiments and implementations can be combined with each other.

参见图1,本发明的基于FPGA的实时图像去马赛克方法,具体包括以下步骤:Referring to Fig. 1, the FPGA-based real-time image demosaicing method of the present invention specifically comprises the following steps:

(1)确定RAW域图像的排列模式、图像分辨率大小(rows × cols)、量化位宽K、每个时钟输入像素点数(NPPC1)和每个时钟输出像素点数(NPPC2)。(1) Determine the arrangement mode of the RAW domain image, the image resolution size (rows × cols), the quantization bit width K, the number of input pixels per clock (NPPC1) and the number of output pixels per clock (NPPC2).

本实施例中,RAW域图像的排列模式包括RGGB、GRBG、BGGR和GBRG四种,因此需要先确定RAW域图像采用的是上述四种排列模式中的哪一种排列模式。其中,RGGB的排列模式如图2所示,GRBG的排列模式如图3所示,BGGR的排列模式如图4所示,GBRG的排列模式如图5所示。此外,为方便后续计算,将与R同行的G记为Gr,与B同行的G记为Gb。In this embodiment, the arrangement modes of the RAW domain images include four types: RGGB, GRBG, BGGR, and GBRG. Therefore, it is necessary to first determine which arrangement mode among the above four arrangement modes is used for the RAW domain images. Among them, the arrangement pattern of RGGB is shown in FIG. 2 , the arrangement pattern of GRBG is shown in FIG. 3 , the arrangement pattern of BGGR is shown in FIG. 4 , and the arrangement pattern of GBRG is shown in FIG. 5 . In addition, for the convenience of subsequent calculations, the G that goes with R is denoted as Gr, and the G that goes with B is denoted as Gb.

具体地,在接收一幅图起始确定并锁存前端输入的RAW域图像的排列方式、图像分辨率大小(rows × cols)、图像的量化位宽K、每个时钟输入像素点数(NPPC1)和每个时钟输出像素点数(NPPC2),并对这些参数进行锁存,可以有效防止图像处理中的设置发生变化从而引起错误。Specifically, at the beginning of receiving a picture, determine and latch the arrangement of the RAW domain image input by the front end, the image resolution size (rows × cols), the quantization bit width K of the image, and the number of pixels per clock input (NPPC1) And the number of pixels output per clock (NPPC2), and these parameters are latched, which can effectively prevent the settings in the image processing from changing and causing errors.

本实施例中,每个时钟输出像素点数大于等于每个时钟输入像素点数,即NPPC2≥NPPC1。例如,可以配置每个时钟输入1个像素点,每个时钟输出1、2、4、8个像素点;可以配置每个时钟输入2个像素点,每个时钟输出2、4、8个像素点,但是每个时钟输出像素点数不能小于2。In this embodiment, the number of pixels output by each clock is greater than or equal to the number of pixels input by each clock, that is, NPPC2≥NPPC1. For example, you can configure each clock to input 1 pixel, and each clock to output 1, 2, 4, and 8 pixels; you can configure each clock to input 2 pixels, and each clock to output 2, 4, and 8 pixels points, but the number of pixels per clock output cannot be less than 2.

(2)确定不同分量的插值模板。(2) Determine the interpolation templates for different components.

本实施例中,分量的插值模板是一个矩阵,其大小为M×N,表示M行×N列的矩阵。应当理解的是,该矩阵的大小具体根据实际情况而定。In this embodiment, the component interpolation template is a matrix with a size of M×N, representing a matrix of M rows×N columns. It should be understood that the size of the matrix is determined according to actual conditions.

(2.1)确定R通道上的G分量插值模板。(2.1) Determine the G component interpolation template on the R channel.

(2.2)确定B通道上的G分量插值模板。(2.2) Determine the G component interpolation template on the B channel.

(2.3)确定Gr通道上的R分量插值模板。(2.3) Determine the R component interpolation template on the Gr channel.

(2.4)确定Gr通道上的B分量插值模板。(2.4) Determine the B component interpolation template on the Gr channel.

(2.5)确定Gb通道上的R分量插值模板。(2.5) Determine the R component interpolation template on the Gb channel.

(2.6)确定Gb通道上的B分量插值模板。(2.6) Determine the B component interpolation template on the Gb channel.

(2.7)确定R通道上的B分量插值模板。(2.7) Determine the B component interpolation template on the R channel.

(2.8)确定B通道上的R分量插值模板。(2.8) Determine the R component interpolation template on the B channel.

本实施例中,可以支持多种插值模板输入,可以采用双线性插值法、高质量线性插值(High quality linear interpolation,HQLI)法或其他方法确定不同分量的插值模板。In this embodiment, input of multiple interpolation templates may be supported, and interpolation templates of different components may be determined by using a bilinear interpolation method, a high quality linear interpolation (High quality linear interpolation, HQLI) method, or other methods.

示例性地,以图3所示的GRBG排列模式为例,采用双线性插值法确定的插值模板如图6-图9所示,该插值模板表示为矩阵,其大小为3×3,即M=3,N=3。其中,Gr通道上的B分量和Gb通道上的R分量插值模板如图6所示,Gr通道上的R分量和Gb通道上的B分量插值模板如图7所示,R通道上的B分量和B通道上的R分量插值模板如图8所示,R通道上的G分量和B通道上的G分量插值模板如图9所示。Exemplarily, taking the GRBG arrangement pattern shown in Figure 3 as an example, the interpolation template determined by the bilinear interpolation method is shown in Figure 6-Figure 9, and the interpolation template is expressed as a matrix with a size of 3×3, namely M=3, N=3. Among them, the B component on the Gr channel and the R component interpolation template on the Gb channel are shown in Figure 6, the R component on the Gr channel and the B component interpolation template on the Gb channel are shown in Figure 7, and the B component on the R channel The R component interpolation templates on the R and B channels are shown in FIG. 8 , and the G component interpolation templates on the R channel and the G component interpolation templates on the B channel are shown in FIG. 9 .

示例性地,以图3所示的GRBG排列模式为例,采用高质量线性插值(High qualitylinear interpolation,HQLI)法确定的插值模板如图10-图13所示,该插值模板表示为矩阵,其大小为5×5,即M=5,N=5。其中,Gr通道的B分量和Gb通道的R分量插值模板如图10所示,Gr通道的R分量和Gb通道的B分量插值模板如图11所示,R通道的G分量和B通道的G分量插值模板如图12所示,R通道的B分量和B通道的R分量插值模板如图13所示。Exemplarily, taking the GRBG arrangement pattern shown in Figure 3 as an example, the interpolation template determined by the High quality linear interpolation (HQLI) method is shown in Figure 10-Figure 13, the interpolation template is expressed as a matrix, its The size is 5×5, that is, M=5, N=5. Among them, the B component of the Gr channel and the R component interpolation template of the Gb channel are shown in Figure 10, the R component of the Gr channel and the B component interpolation template of the Gb channel are shown in Figure 11, the G component of the R channel and the G component of the B channel The component interpolation template is shown in Figure 12, and the B component of the R channel and the R component interpolation template of the B channel are shown in Figure 13.

应当理解的是,双线性插值法计算更简单,占用资源少,延迟更低;而HQLI法考虑了插值窗内像素点的相关信息,插值效果更好;因此,可以根据实际情况选择合适的插值模板。当然,也可以选择其他方法中的模板,例如也可以外加梯度计算模块,综合梯度和边界信息,实时计算最合适的插值模板输入去马赛克模块进行插值。It should be understood that the bilinear interpolation method is simpler to calculate, occupies less resources, and has lower delay; while the HQLI method takes into account the relevant information of the pixels in the interpolation window, and the interpolation effect is better; therefore, the appropriate one can be selected according to the actual situation. Interpolation template. Of course, templates in other methods can also be selected, for example, a gradient calculation module can also be added to integrate gradient and boundary information, and the most suitable interpolation template can be calculated in real time and input to the demosaic module for interpolation.

(3)根据步骤(2)获取的插值模板对步骤(1)中的RAW域图像进行行列流水线缓存,以获取待插值矩阵和中心像素点的行计数和列计数。(3) According to the interpolation template obtained in step (2), the RAW domain image in step (1) is cached in a row-column pipeline to obtain the row count and column count of the matrix to be interpolated and the central pixel.

(3.1)在原始数据后串联多个行缓存器;其中行缓存器的数量根据步骤(2)获取的插值模板的大小确定。(3.1) Multiple row buffers are connected in series behind the original data; the number of row buffers is determined according to the size of the interpolation template obtained in step (2).

具体地,根据步骤(2)获取的插值模板的大小为M×N,在原始数据后将M-1个行缓存器进行串联。Specifically, the size of the interpolation template obtained according to step (2) is M×N, and M−1 line buffers are connected in series after the original data.

(3.2)分别在每个行缓存器和原始数据后串联多个D触发器,以获取大小为M×(NPPC2+N-1)的待插值矩阵,并根据RAW域图像分辨率大小进行行列计数,以获取中心像素点的行计数和列计数;其中D触发器的数量根据步骤(1)中确定的RAW域图像的每个时钟输入像素点数和每个时钟输出像素点数以及步骤(2)获取的插值模板的大小确定。(3.2) Connect multiple D flip-flops in series after each row buffer and original data to obtain a matrix to be interpolated with a size of M×(NPPC2+N-1), and count rows and columns according to the resolution of the RAW domain image , to obtain the row count and column count of the central pixel; where the number of D flip-flops is obtained according to the number of input pixels per clock and the number of output pixels per clock of the RAW domain image determined in step (1) and step (2) The size of the interpolation template is determined.

具体地,根据步骤(1)中确定的RAW域图像的每个时钟输入像素点数和每个时钟输出像素点数以及步骤(2)获取的插值模板的大小确定串联的D触发器的数量,即分别在每个行缓存器和原始数据后串联个D触发器,/>代表向上取整,可以得到大小为M×(NPPC2+N-1)的待插值矩阵,如图14所示。Specifically, the number of D flip-flops connected in series is determined according to the number of input pixels per clock and the number of output pixels per clock of the RAW domain image determined in step (1) and the size of the interpolation template obtained in step (2), that is, respectively concatenated after each row buffer and raw data D flip-flops, /> Represents rounding up, and a matrix to be interpolated with a size of M×(NPPC2+N-1) can be obtained, as shown in Figure 14.

需要说明的是,串联D触发器可以将原始数据等相关数据延迟一个周期,例如,在每个时钟上升沿顺序发送D0、D1、D2、D3,如果不加D触发器,在某个时刻只能得到一个数据,如果串联三个D触发器,在发送D3时刻,第一个D触发器后的数据为D2,第二个D触发器后的数据为D1,第三个D触发器后的数据为D0,可以同时得到4个数据。应当理解的是,在数字逻辑中一般采用D触发器做延迟用,当然,也可以更换成其他触发器用于延迟。It should be noted that the series D flip-flop can delay the original data and other related data by one cycle. For example, D0, D1, D2, and D3 are sent sequentially on each rising edge of the clock. If the D flip-flop is not added, at a certain moment only One data can be obtained. If three D flip-flops are connected in series, at the moment of sending D3, the data after the first D flip-flop is D2, the data after the second D flip-flop is D1, and the data after the third D flip-flop The data is D0, and 4 data can be obtained at the same time. It should be understood that in digital logic, D flip-flops are generally used for delay, and of course, other flip-flops can also be used for delay.

另一方面,根据RAW域图像分辨率大小进行行列计数,输出待插值矩阵的同时输出待插值矩阵中心像素点的行计数和列计数。具体地,M×(NPPC2+N-1)为待插值矩阵的大小,可认为是窗函数的大小,这个窗函数在原输入图像滑动,选取数据与如步骤(2.8)的插值模板进行乘加操作,计算得到窗函数中心点的缺失通道信息。例如原图大小为500×500像素,窗函数大小为5×5像素,按照插值模板进行乘加操作,可以获取插值中心的行计数和列计数,即中心像素点的行计数和列计数。On the other hand, count the rows and columns according to the resolution of the RAW domain image, and output the row count and column count of the central pixel of the matrix to be interpolated while outputting the matrix to be interpolated. Specifically, M×(NPPC2+N-1) is the size of the matrix to be interpolated, which can be regarded as the size of the window function. This window function slides on the original input image, and the selected data is multiplied and added with the interpolation template as in step (2.8). , calculate the missing channel information of the center point of the window function. For example, the size of the original image is 500×500 pixels, and the size of the window function is 5×5 pixels. By multiplying and adding according to the interpolation template, the row count and column count of the interpolation center can be obtained, that is, the row count and column count of the center pixel.

(4)根据步骤(2)获取的插值模板和步骤(3)获取的待插值矩阵计算中心像素点缺失的通道分量。(4) According to the interpolation template obtained in step (2) and the matrix to be interpolated obtained in step (3), calculate the missing channel component of the central pixel.

(4.1)对步骤(3)获取的大小为M×(NPPC2+N-1)的待插值矩阵进行拆分,以获取NPPC2个大小为M×N的待插值矩阵,其中NPPC2表示RAW域图像的每个时钟输出像素点数。(4.1) Split the matrix to be interpolated with a size of M×(NPPC2+N-1) obtained in step (3) to obtain NPPC2 matrixes to be interpolated with a size of M×N, where NPPC2 represents the RAW domain image Output pixels per clock.

本实施例中,步骤(3)获取的待插值矩阵大小为M×(NPPC2+N-1),插值模板的大小为M×N,对该待插值矩阵进行拆分,可以获取NPPC2个大小为M×N的待插值矩阵,如图17所示。In this embodiment, the size of the matrix to be interpolated obtained in step (3) is M×(NPPC2+N-1), the size of the interpolation template is M×N, and the matrix to be interpolated can be split to obtain NPPC2 with a size of The M×N matrix to be interpolated is shown in Figure 17.

(4.2)根据步骤(3)获取的行计数和列计数并行确定NPPC2个待插值矩阵的中心像素点通道,是R通道、B通道、Gr通道、还是Gb通道。(4.2) According to the row count and column count obtained in step (3), determine in parallel whether the central pixel channel of the NPPC2 matrices to be interpolated is the R channel, the B channel, the Gr channel, or the Gb channel.

具体地,以GRBG排列模式为例,步骤(3)获取到的行计数为0~rows-1,列计数为0~cols-1,当行计数和列计数均为偶数时,当前待插值矩阵的中心像素点为Gr分量;当行计数为偶数,列计数为奇数时,当前待插值矩阵的中心像素点为R分量;当行计数为奇数,列计数为偶数时,当前待插值矩阵的中心像素点为B分量;当行计数和列计数均为奇数时,当前待插值矩阵的中心像素点为Gb分量。Specifically, taking the GRBG arrangement mode as an example, the row count obtained in step (3) is 0~rows-1, and the column count is 0~cols-1. When the row count and column count are both even numbers, the current matrix to be interpolated The central pixel is the Gr component; when the row count is even and the column count is odd, the central pixel of the matrix to be interpolated is the R component; when the row count is odd and the column count is even, the central pixel of the current matrix to be interpolated is B component; when the row count and column count are both odd, the center pixel of the current matrix to be interpolated is the Gb component.

应当理解的是,待插值矩阵的中心像素点在Gr通道中的值,被称作中心像素点的Gr分量,故待插值矩阵的中心像素点为Gr分量表示待插值矩阵的中心像素点通道为Gr通道。It should be understood that the value of the central pixel of the matrix to be interpolated in the Gr channel is called the Gr component of the central pixel, so the central pixel of the matrix to be interpolated is the Gr component, indicating that the channel of the central pixel of the matrix to be interpolated is Gr channel.

(4.3)确定待插值矩阵是否包括边界位置像素,若待插值矩阵包括边界位置像素,则对待插值矩阵的缺失元素进行镜像映射;否则,直接进入步骤(4.4)。(4.3) Determine whether the matrix to be interpolated includes boundary position pixels, and if the matrix to be interpolated includes boundary position pixels, perform mirror mapping on the missing elements of the matrix to be interpolated; otherwise, go directly to step (4.4).

具体地,以GRBG排列模式,其大小为5×5,NPPC1=NPPC2=1为例,如图15所示,其余部分的缺失元素通过已知部分的元素进行镜像映射可以获得,第1行为第5行映射,第2行为第4行映射,第1列为第5列映射,第2列为第4列映射,映射后可以保持四类像素的排列顺序。Specifically, take the GRBG arrangement mode, whose size is 5×5, NPPC1=NPPC2=1 as an example, as shown in Figure 15, the remaining missing elements can be obtained by mirroring the elements of the known part, the first row 5 rows of mapping, the second row is the mapping of the fourth row, the first column is the mapping of the fifth column, and the second column is the mapping of the fourth column. After mapping, the arrangement order of the four types of pixels can be maintained.

示例性地,如图16所示,最后一个点的待插值矩阵仅有左上角部分在图像中,其余部分通过镜像映射得到,第4行为第2行映射,第5行为第1行映射,第4列为第2列映射,第5列为第1列映射。Exemplarily, as shown in Figure 16, only the upper left part of the matrix to be interpolated at the last point is in the image, and the rest is obtained through mirror mapping. The fourth row is mapped to the second row, the fifth row is mapped to the first row, and the Column 4 is mapped to column 2, and column 5 is mapped to column 1.

综上所述,同样图像上边界的待插值矩阵的上半部分,图像下边界的待插值矩阵的下半部分,图像左边界的待插值矩阵的左半部分和图像右边界的待插值矩阵的右半部分均通过上述方法进行镜像映射得到。In summary, the upper half of the matrix to be interpolated at the upper boundary of the image, the lower half of the matrix to be interpolated at the lower boundary of the image, the left half of the matrix to be interpolated at the left boundary of the image, and the matrix to be interpolated at the right boundary of the image The right half is obtained through mirror mapping by the above method.

(4.4)将待插值模板左移8位,以将待插值矩阵扩大256倍,可以保证计算结果的小数位精度。(4.4) Shift the template to be interpolated to the left by 8 bits to expand the matrix to be interpolated by 256 times, which can ensure the precision of the decimal place of the calculation result.

(4.5)根据每个待插值矩阵的中心像素点通道以及对应的待插值矩阵和插值模板并行NPPC2个插值计算模块计算中心像素点缺失的两个分量。(4.5) According to the central pixel point channel of each matrix to be interpolated and the corresponding matrix to be interpolated and the interpolation template, two parallel NPPC interpolation calculation modules are used to calculate the two missing components of the central pixel point.

本实施例中,根据相应的待插值矩阵和插值模板并行NPPC2个插值计算模块,根据NPPC2个待插值矩阵中的每个待插值矩阵的中心像素点通道的类型计算缺失的两个分量。若待插值矩阵的中心像素点通道为Gr通道,选取Gr通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取Gr通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为Gb通道,选取Gb通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取Gb通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为R通道,选取R通道上的G分量插值模板与待插值矩阵进行点乘以获取缺失的G分量,选取R通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为B通道,选取B通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取B通道上的G分量插值模板与待插值矩阵进行点乘以获取缺失的G分量。In this embodiment, the NPPC2 interpolation calculation modules are parallelized according to the corresponding matrix to be interpolated and the interpolation template, and the missing two components are calculated according to the type of the central pixel channel of each matrix to be interpolated in the 2 matrices to be interpolated. If the center pixel point channel of the matrix to be interpolated is the Gr channel, select the R component interpolation template on the Gr channel and the matrix to be interpolated to perform point multiplication to obtain the missing R component, and select the B component interpolation template on the Gr channel to perform multiplication with the matrix to be interpolated. Point multiplication to obtain the missing B component; if the central pixel point channel of the matrix to be interpolated is the Gb channel, select the R component interpolation template on the Gb channel and the matrix to be interpolated to perform point multiplication to obtain the missing R component, and select the Gb channel on the Do point multiplication between the B component interpolation template and the matrix to be interpolated to obtain the missing B component; if the center pixel channel of the matrix to be interpolated is the R channel, select the G component interpolation template on the R channel and perform point multiplication with the matrix to be interpolated to obtain the missing G component, select the B component interpolation template on the R channel and perform point multiplication with the matrix to be interpolated to obtain the missing B component; if the center pixel point channel of the matrix to be interpolated is the B channel, select the R component interpolation template on the B channel and Perform point multiplication of the matrix to be interpolated to obtain the missing R component, and select the G component interpolation template on the B channel to perform point multiplication with the matrix to be interpolated to obtain the missing G component.

(5)对步骤(4)获取的分量进行转换处理,并将中心像素点的R、G、B按顺序拼接。(5) Convert the components obtained in step (4), and stitch the R, G, and B of the center pixel in order.

(5.1)将步骤(4)获取的分量缩小256倍。(5.1) Reduce the components obtained in step (4) by 256 times.

应当理解的是,由于步骤(4.4)中将待插值矩阵扩大了256倍,因此,需要根据四舍五入原则将步骤(4.5)中计算得到的分量缩小256倍。It should be understood that since the matrix to be interpolated is enlarged by 256 times in step (4.4), the components calculated in step (4.5) need to be reduced by 256 times according to the rounding principle.

(5.2)对缩小后的分量进行判定:若缩小后的分量小于0,则将其转换为0;若缩小后的分量大于,则将其转换为/>;若缩小后的分量小于等于/>且大于等于0,则不做转换,保持原值;其中K表示量化位宽。(5.2) Determine the reduced component: if the reduced component is less than 0, convert it to 0; if the reduced component is greater than , it is converted to /> ; If the reduced component is less than or equal to /> And greater than or equal to 0, no conversion will be performed and the original value will be kept; where K represents the quantization bit width.

具体地,可以根据下列公式进行转换:Specifically, the conversion can be performed according to the following formula:

其中,K为量化位宽。Among them, K is the quantization bit width.

(5.3)将NPPC2个中心像素点的R、G、B按顺序拼接后输出。(5.3) The R, G, and B of the 2 central pixels of NPPC are spliced in order and output.

应当理解的是,可以根据实际需要进行拼接,例如[R,G,B]或者[B,G,R]等。It should be understood that splicing can be performed according to actual needs, such as [R, G, B] or [B, G, R] and so on.

本发明采用流水线的设计方法,处理图像的延迟低;本发明可利用像素间的相关信息有效提高插值质量,计算复杂度低,计算灵活,可灵活适配不同分辨率、不同量化位宽、不同RAW域排列模式、不同每个时钟输入像素点数和每个时钟输出像素点数的情况,可以适配前端不同的输入图像。The present invention adopts the design method of the pipeline, and the delay of image processing is low; the present invention can effectively improve the interpolation quality by using the relevant information between pixels, the calculation complexity is low, the calculation is flexible, and it can be flexibly adapted to different resolutions, different quantization bit widths, different The RAW domain arrangement mode, the number of pixels per clock input and the number of pixels per clock output can be adapted to different input images at the front end.

与前述基于FPGA的实时图像去马赛克方法的实施例相对应,本发明还提供了基于FPGA的实时图像去马赛克装置的实施例。Corresponding to the foregoing embodiments of the FPGA-based real-time image demosaicing method, the present invention also provides embodiments of an FPGA-based real-time image demosaicing device.

参见图18,本发明实施例提供的一种基于FPGA的实时图像去马赛克装置,包括一个或多个处理器,用于实现上述实施例中的基于FPGA的实时图像去马赛克方法。Referring to FIG. 18 , an FPGA-based real-time image demosaicing device provided by an embodiment of the present invention includes one or more processors for implementing the FPGA-based real-time image demosaicing method in the foregoing embodiments.

本发明基于FPGA的实时图像去马赛克装置的实施例可以应用在任意具备数据处理能力的设备上,该任意具备数据处理能力的设备可以为诸如计算机等设备或装置。装置实施例可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。以软件实现为例,作为一个逻辑意义上的装置,是通过其所在任意具备数据处理能力的设备的处理器将非易失性存储器中对应的计算机程序指令读取到内存中运行形成的。从硬件层面而言,如图18所示,为本发明基于FPGA的实时图像去马赛克装置所在任意具备数据处理能力的设备的一种硬件结构图,除了图18所示的处理器、内存、网络接口、以及非易失性存储器之外,实施例中装置所在的任意具备数据处理能力的设备通常根据该任意具备数据处理能力的设备的实际功能,还可以包括其他硬件,对此不再赘述。The embodiment of the FPGA-based real-time image demosaicing device of the present invention can be applied to any device with data processing capability, and any device with data processing capability can be a device or device such as a computer. The device embodiments can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory for operation by the processor of any device capable of data processing. From the hardware level, as shown in Figure 18, it is a hardware structure diagram of any device with data processing capabilities where the FPGA-based real-time image demosaicing device of the present invention is located, except for the processor, memory, and network shown in Figure 18 In addition to the interface and the non-volatile memory, any device with data processing capability where the device in the embodiment is usually located may also include other hardware according to the actual function of any device with data processing capability, which will not be repeated here.

上述装置中各个单元的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。For the implementation process of the functions and effects of each unit in the above device, please refer to the implementation process of the corresponding steps in the above method for details, and will not be repeated here.

对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本发明方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。As for the device embodiment, since it basically corresponds to the method embodiment, for related parts, please refer to the part description of the method embodiment. The device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network elements. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present invention. It can be understood and implemented by those skilled in the art without creative effort.

本发明实施例还提供一种计算机可读存储介质,其上存储有程序,该程序被处理器执行时,实现上述实施例中的基于FPGA的实时图像去马赛克方法。An embodiment of the present invention also provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the FPGA-based real-time image demosaicing method in the foregoing embodiments is implemented.

所述计算机可读存储介质可以是前述任一实施例所述的任意具备数据处理能力的设备的内部存储单元,例如硬盘或内存。所述计算机可读存储介质也可以是任意具备数据处理能力的设备,例如所述设备上配备的插接式硬盘、智能存储卡(Smart Media Card,SMC)、SD卡、闪存卡(Flash Card)等。进一步的,所述计算机可读存储介质还可以既包括任意具备数据处理能力的设备的内部存储单元也包括外部存储设备。所述计算机可读存储介质用于存储所述计算机程序以及所述任意具备数据处理能力的设备所需的其他程序和数据,还可以用于暂时地存储已经输出或者将要输出的数据。The computer-readable storage medium may be an internal storage unit of any device capable of data processing described in any of the foregoing embodiments, such as a hard disk or a memory. The computer-readable storage medium may also be any device capable of data processing, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), an SD card, or a flash memory card (Flash Card) equipped on the device. wait. Further, the computer-readable storage medium may also include both an internal storage unit of any device capable of data processing and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by any device capable of data processing, and may also be used to temporarily store data that has been output or will be output.

以上实施例仅用于说明本发明的设计思想和特点,其目的在于使本领域内的技术人员能够了解本发明的内容并据以实施,本发明的保护范围不限于上述实施例。所以,凡依据本发明所揭示的原理、设计思路所作的等同变化或修饰,均在本发明的保护范围之内。The above embodiments are only used to illustrate the design concept and characteristics of the present invention, and its purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, all equivalent changes or modifications based on the principles and design ideas disclosed in the present invention are within the protection scope of the present invention.

Claims (8)

1.一种基于FPGA的实时图像去马赛克方法,其特征在于,包括以下步骤:1. a real-time image demosaicing method based on FPGA, is characterized in that, comprises the following steps: (1)确定RAW域图像的排列模式、图像分辨率大小、量化位宽、每个时钟输入像素点数和每个时钟输出像素点数;(1) Determine the arrangement mode of the RAW domain image, the image resolution size, the quantization bit width, the number of input pixels per clock and the number of output pixels per clock; (2)确定不同分量的插值模板;(2) determine the interpolation template of different components; (3)根据所述步骤(2)获取的插值模板对所述步骤(1)中的RAW域图像进行行列流水线缓存,以获取待插值矩阵和中心像素点的行计数和列计数;(3) performing row-column pipeline buffering on the RAW domain image in the step (1) according to the interpolation template obtained in the step (2), to obtain the row count and the column count of the matrix to be interpolated and the center pixel; (4)根据所述步骤(2)获取的插值模板和所述步骤(3)获取的待插值矩阵计算中心像素点缺失的通道分量;(4) according to the interpolation template that described step (2) obtains and the matrix to be interpolated that described step (3) obtains, calculate the missing channel component of central pixel point; 所述步骤(4)包括以下子步骤:Described step (4) comprises following substep: (4.1)对所述步骤(3)获取的大小为M×(NPPC2+N-1)的待插值矩阵进行拆分,以获取NPPC2个大小为M×N的待插值矩阵,其中NPPC2表示RAW域图像的每个时钟输出像素点数;(4.1) split the matrix to be interpolated that is M×(NPPC2+N-1) obtained in step (3) to obtain NPPC2 matrixes to be interpolated that are M×N in size, where NPPC2 represents the RAW domain The number of pixels output per clock of the image; (4.2)根据所述步骤(3)获取的行计数和列计数并行确定NPPC2个待插值矩阵的中心像素点通道,是R通道、B通道、Gr通道、还是Gb通道;(4.2) according to the row count and column count that described step (3) obtains, determine in parallel the central pixel point channel of NPPC2 interpolation matrices, be R channel, B channel, Gr channel or Gb channel; (4.3)确定待插值矩阵是否包括边界位置像素,若待插值矩阵包括边界位置像素,则对待插值矩阵的缺失元素进行镜像映射;否则,直接进入步骤(4.4);(4.3) Determine whether the matrix to be interpolated includes boundary position pixels, if the matrix to be interpolated comprises boundary position pixels, then the missing elements of the matrix to be interpolated are mirrored; otherwise, directly enter step (4.4); (4.4)将待插值模板左移8位,以将待插值矩阵扩大256倍;(4.4) Shift the template to be interpolated by 8 bits to the left to enlarge the matrix to be interpolated by 256 times; (4.5)根据每个待插值矩阵的中心像素点通道以及对应的待插值矩阵和插值模板并行NPPC2个插值计算模块计算中心像素点缺失的两个分量;(4.5) According to the central pixel point channel of each matrix to be interpolated and the corresponding matrix to be interpolated and the interpolation template parallel NPPC2 interpolation calculation modules to calculate the two missing components of the central pixel; 所述步骤(4.5)具体包括:若待插值矩阵的中心像素点通道为Gr通道,选取Gr通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取Gr通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为Gb通道,选取Gb通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取Gb通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为R通道,选取R通道上的G分量插值模板与待插值矩阵进行点乘以获取缺失的G分量,选取R通道上的B分量插值模板与待插值矩阵进行点乘以获取缺失的B分量;若待插值矩阵的中心像素点通道为B通道,选取B通道上的R分量插值模板与待插值矩阵进行点乘以获取缺失的R分量,选取B通道上的G分量插值模板与待插值矩阵进行点乘以获取缺失的G分量;The step (4.5) specifically includes: if the central pixel point channel of the matrix to be interpolated is the Gr channel, select the R component interpolation template on the Gr channel and perform point multiplication with the matrix to be interpolated to obtain the missing R component, and select the R component on the Gr channel Perform point multiplication between the B component interpolation template and the matrix to be interpolated to obtain the missing B component; if the center pixel channel of the matrix to be interpolated is the Gb channel, select the R component interpolation template on the Gb channel and perform point multiplication with the matrix to be interpolated to obtain the missing R component, select the B component interpolation template on the Gb channel and perform point multiplication with the matrix to be interpolated to obtain the missing B component; if the center pixel point channel of the matrix to be interpolated is the R channel, select the G component interpolation template on the R channel and Perform point multiplication of the matrix to be interpolated to obtain the missing G component, select the B component interpolation template on the R channel and perform point multiplication with the matrix to be interpolated to obtain the missing B component; if the center pixel channel of the matrix to be interpolated is the B channel, select The R component interpolation template on the B channel is multiplied by the matrix to be interpolated to obtain the missing R component, and the G component interpolation template on the B channel is selected to be multiplied by the matrix to be interpolated to obtain the missing G component; (5)对所述步骤(4)获取的分量进行转换处理,并将中心像素点的R、G、B按顺序拼接。(5) Perform conversion processing on the components obtained in the step (4), and stitch R, G, and B of the central pixel in order. 2.根据权利要求1所述的基于FPGA的实时图像去马赛克方法,其特征在于,所述排列模式包括RGGB、GRBG、BGGR和GBRG。2. FPGA-based real-time image demosaic method according to claim 1, is characterized in that, described arrangement pattern comprises RGGB, GRBG, BGGR and GBRG. 3.根据权利要求1所述的基于FPGA的实时图像去马赛克方法,其特征在于,所述每个时钟输出像素点数大于等于每个时钟输入像素点数。3. FPGA-based real-time image demosaic method according to claim 1, is characterized in that, described each clock output pixel number is greater than or equal to each clock input pixel number. 4.根据权利要求1所述的基于FPGA的实时图像去马赛克方法,其特征在于,所述步骤(2)包括以下子步骤:4. the real-time image demosaicing method based on FPGA according to claim 1, is characterized in that, described step (2) comprises the following substeps: (2.1)确定R通道上的G分量插值模板;(2.1) determine the G component interpolation template on the R channel; (2.2)确定B通道上的G分量插值模板;(2.2) determine the G component interpolation template on the B channel; (2.3)确定Gr通道上的R分量插值模板;(2.3) determine the R component interpolation template on the Gr channel; (2.4)确定Gr通道上的B分量插值模板;(2.4) determine the B component interpolation template on the Gr channel; (2.5)确定Gb通道上的R分量插值模板;(2.5) determine the R component interpolation template on the Gb channel; (2.6)确定Gb通道上的B分量插值模板;(2.6) determine the B component interpolation template on the Gb channel; (2.7)确定R通道上的B分量插值模板;(2.7) determine the B component interpolation template on the R channel; (2.8)确定B通道上的R分量插值模板。(2.8) Determine the R component interpolation template on the B channel. 5.根据权利要求1所述的基于FPGA的实时图像去马赛克方法,其特征在于,所述步骤(3)包括以下子步骤:5. the FPGA-based real-time image demosaicing method according to claim 1, is characterized in that, described step (3) comprises the following substeps: (3.1)在原始数据后串联多个行缓存器;其中行缓存器的数量根据所述步骤(2)获取的插值模板的大小确定;(3.1) a plurality of line buffers are connected in series after the original data; wherein the quantity of the line buffers is determined according to the size of the interpolation template obtained in the step (2); (3.2)分别在每个行缓存器和原始数据后串联多个D触发器,以获取大小为M×(NPPC2+N-1)的待插值矩阵,并根据RAW域图像分辨率大小进行行列计数,以获取中心像素点的行计数和列计数;其中D触发器的数量根据所述步骤(1)中确定的RAW域图像的每个时钟输入像素点数和每个时钟输出像素点数以及所述步骤(2)获取的插值模板的大小确定。(3.2) Multiple D flip-flops are connected in series after each row buffer and original data to obtain a matrix to be interpolated with a size of M×(NPPC2+N-1), and count rows and columns according to the resolution of the RAW domain image , to obtain the row count and column count of the central pixel; wherein the number of D flip-flops is based on the number of input pixels per clock and the number of pixels output by each clock of the RAW domain image determined in the step (1) and the steps (2) The size of the obtained interpolation template is determined. 6.根据权利要求1所述的基于FPGA的实时图像去马赛克方法,其特征在于,所述步骤(5)包括以下子步骤:6. the real-time image demosaic method based on FPGA according to claim 1, is characterized in that, described step (5) comprises following substep: (5.1)将所述步骤(4)获取的分量缩小256倍;(5.1) reducing the component obtained by the step (4) by 256 times; (5.2)对缩小后的分量进行判定:若缩小后的分量小于0,则将其转换为0;若缩小后的分量大于2K-1,则将其转换为2K-1;若缩小后的分量小于等于2K-1且大于等于0,则不做转换,保持原值;其中K表示量化位宽;(5.2) Determine the reduced component: if the reduced component is less than 0, convert it to 0; if the reduced component is greater than 2 K -1, convert it to 2 K -1; if the reduced component If the component is less than or equal to 2 K -1 and greater than or equal to 0, no conversion will be performed and the original value will be kept; where K represents the quantization bit width; (5.3)将NPPC2个中心像素点的R、G、B按顺序拼接后输出。(5.3) The R, G, and B of the 2 central pixels of NPPC are spliced in order and output. 7.一种基于FPGA的实时图像去马赛克装置,其特征在于,包括一个或多个处理器,用于实现权利要求1-6中任一项所述的基于FPGA的实时图像去马赛克方法。7. An FPGA-based real-time image demosaicing device, characterized in that it comprises one or more processors for implementing the FPGA-based real-time image demosaicing method according to any one of claims 1-6. 8.一种计算机可读存储介质,其特征在于,其上存储有程序,该程序被处理器执行时,用于实现权利要求1-6中任一项所述的基于FPGA的实时图像去马赛克方法。8. A computer-readable storage medium, characterized in that a program is stored thereon, and when the program is executed by a processor, it is used to realize the real-time image demosaicing based on FPGA according to any one of claims 1-6 method.
CN202310618823.XA 2023-05-30 2023-05-30 A FPGA-based real-time image demosaicing method, device and medium Active CN116342394B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310618823.XA CN116342394B (en) 2023-05-30 2023-05-30 A FPGA-based real-time image demosaicing method, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310618823.XA CN116342394B (en) 2023-05-30 2023-05-30 A FPGA-based real-time image demosaicing method, device and medium

Publications (2)

Publication Number Publication Date
CN116342394A CN116342394A (en) 2023-06-27
CN116342394B true CN116342394B (en) 2023-08-18

Family

ID=86879064

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310618823.XA Active CN116342394B (en) 2023-05-30 2023-05-30 A FPGA-based real-time image demosaicing method, device and medium

Country Status (1)

Country Link
CN (1) CN116342394B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117291807B (en) * 2023-11-23 2024-03-15 广东匠芯创科技有限公司 Image demosaicing method and device, electronic equipment and storage medium
CN118158551B (en) * 2024-04-30 2024-07-23 合肥埃科光电科技股份有限公司 A de-mosaicing method, system and medium based on FPGA

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102663719A (en) * 2012-03-19 2012-09-12 西安电子科技大学 Bayer-pattern CFA image demosaicking method based on non-local mean
CN111681191A (en) * 2020-05-11 2020-09-18 安徽百诚慧通科技有限公司 Color image demosaicing method and system based on FPGA and storage medium
WO2021003594A1 (en) * 2019-07-05 2021-01-14 Baidu.Com Times Technology (Beijing) Co., Ltd. Systems and methods for multispectral image demosaicking using deep panchromatic image guided residual interpolation
CN114066736A (en) * 2022-01-17 2022-02-18 电子科技大学 Template information assisted color image demosaicing method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150055861A1 (en) * 2013-08-23 2015-02-26 Amlogic Co., Ltd Methods and Systems for Image Demosaicing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102663719A (en) * 2012-03-19 2012-09-12 西安电子科技大学 Bayer-pattern CFA image demosaicking method based on non-local mean
WO2021003594A1 (en) * 2019-07-05 2021-01-14 Baidu.Com Times Technology (Beijing) Co., Ltd. Systems and methods for multispectral image demosaicking using deep panchromatic image guided residual interpolation
CN111681191A (en) * 2020-05-11 2020-09-18 安徽百诚慧通科技有限公司 Color image demosaicing method and system based on FPGA and storage medium
CN114066736A (en) * 2022-01-17 2022-02-18 电子科技大学 Template information assisted color image demosaicing method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孙辉 ; 柏旭光 ; 孙丽娜 ; 李志强 ; .Bayer图像色彩还原线性插值方法.液晶与显示.2013,(第03期),全文. *

Also Published As

Publication number Publication date
CN116342394A (en) 2023-06-27

Similar Documents

Publication Publication Date Title
CN116342394B (en) A FPGA-based real-time image demosaicing method, device and medium
US10861133B1 (en) Super-resolution video reconstruction method, device, apparatus and computer-readable storage medium
KR102291790B1 (en) Multi-rate processing of image data within an image processing pipeline
US10257447B2 (en) Imaging method, imaging device, and electronic device
US8989509B2 (en) Streaming wavelet transform
CN101416217B (en) Techniques to facilitate use of small line buffers for processing of small or large images
WO2013006512A2 (en) Image signal processor architecture optimized for low-power, processing flexibility, and user experience
CN115086668A (en) A video compression method, system, device and computer-readable storage medium
US8798386B2 (en) Method and system for processing image data on a per tile basis in an image sensor pipeline
JP6284332B2 (en) Image processing apparatus, image processing method, and imaging apparatus
CN100401348C (en) Display device and its control circuit
Gong et al. Design of high-speed real-time sensor image processing based on FPGA and DDR3
CN115147297A (en) An image processing method and device
US20150326808A1 (en) Device and method for processing images
Luo et al. Improved LUT-based image warping for video cameras
US20250024171A1 (en) Image signal processor and imaging system including the same
US20080303917A1 (en) Digital processing cell
CN113256763B (en) Electronic device, image processing method thereof, system-on-chip and medium
CN110602426B (en) A video image edge extraction system
Azgin et al. A high performance alternating projections image demosaicing hardware
GB2516288A (en) Image processing system
JP6415086B2 (en) Image processing apparatus, image processing method, and program
CN101783857B (en) Image matrixing pretreatment method based on FPGA in high-resolution imaging system
CN116342415A (en) Image correction method and device, equipment, chip and storage medium
CN115965528A (en) Super-resolution system and method for high-speed image acquisition

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant