主要内容

Noise Removal and Image Sharpening

这个例子展示了如何实现前端帽dule of an image processing design. This front-end module removes noise and sharpens the image to provide a better initial condition for the subsequent processing.

焦点外的物体导致模糊的图像。相机或视频传感器上的死亡或卡住像素,或来自硬件组件的热噪声,有助于图像中的噪声。在该示例中,前端模块使用来自Vision HDL Toolbox™的两个像素流滤波器块来实现。中值过滤器消除了噪声,图像过滤器锐化图像。该示例将像素流与来自计算机视觉系统工具箱™的全帧块生成的那些进行比较。

This example model provides a hardware-compatible algorithm. You can implement this algorithm on a board using a Xilinx™ Zynq™ reference design. See与基于Zynq的硬件锐化的图像锐化(Vision HDL Toolbox Support Package for Xilinx Zynq-Based Hardware)

榜样

计算机视觉工具箱块一次在整个帧上运行。Vision HDL工具箱块在像素数据流上运行,一次一个像素。Vision HDL工具箱中的转换块,帧为像素和像素到帧,使您能够模拟流式像素设计,以及全帧设计。

noiseremovalandimagesharpeninghdl.slx.系统如下所示。

这following diagram shows the structure of the Full-Frame Behavioral Model subsystem, which consists of the frame-based Median Filter and 2-D FIR Filter. As mentioned before, median filter removes the noise and 2-D FIR Filter is configured to sharpen the image.

这像素流HDL模型subsystem contains the streaming implementation of the median filter and 2-D FIR filter, as shown in the diagram below. You can generate HDL code from the Pixel-Stream HDL Model subsystem.

这Verification subsystem compares the results from full-frame processing with those from pixel-stream processing.

在下面的图表中,中位过滤源视频的一帧模糊和嘈杂的源视频,其发出滤波后的发出版本,以及2-D ​​FIR滤波后的锐化输出。

图像源码

下图显示了图像源子系统。

图像源块导入灰度图像,然后使用名为Blur的MATLAB功能块并添加噪声以模糊图像并注入盐和胡椒噪声。IMFilter函数使用3×3平均内核来模糊图像。通过呼叫innoise(i,'盐和辣椒',d)命令注入盐和胡椒噪声,其中d是定义为盐和胡椒像素与总像素的总像素的比率的噪声密度图片。该密度值由噪声密度恒定块指定,并且它必须在0和1之间。图像源子系统输出完整图像的2-D矩阵。

框架为像素:生成像素流

这框架到像素block converts a full image frame to a pixel stream. The Number of components field is set to 1 for grayscale image input, and the Video format field is 240p to match that of the video source. The sample time of the Video Source is determined by the product of Total pixels per line and Total video lines in the Frame To Pixels block. For more information, see the框架到像素块参考页面。

像素流HDL模型

中值过滤器块用于去除盐和辣椒噪声。要了解更多信息,请参阅中位过滤器块参考页面。

基于滤波器系数,图像滤波器块可用于模糊,锐化或检测中值滤波后恢复图像的边缘。在该示例中,图像滤波器被配置为锐化图像。要了解更多信息,请参阅图像过滤器块参考页面。

帧的像素:将像素流转换回全帧

帧块的像素通过利用同步信号来将像素流转换为完整帧。分别为帧的组件字段和视频格式字段分别设置为1和240p,以匹配视频源的格式。

验证像素流处理设计

如下所示,验证子系统验证了来自全帧行为模型的像素流HDL模型的结果。

这peak signal to noise ratio (PSNR) is calculated between the reference image and the stream processed image. Ideally, the ratio should be inf, indicating that the output image from the Full-Frame Behavioral Model matches that generated from the Pixel-Stream HDL Model.

Generate HDL Code and Verify Its Behavior

要检查和生成此示例中引用的HDL代码,必须具有HDL Coder™许可证。

要生成HDL代码,请使用以下命令:

makehdl('noiseremovalandimagesharpeninghdl / pixel-stream hdl model');

要生成测试台,请使用以下命令:

makehdltb('noiseremovalandimagesharpeninghdl / pixel-stream hdl model');