"Ffmpeg basics" Chinese version - 8. blur, sharpen, and noise removal

8. blur, sharpen and denoising

When the video input contains noise, or we can use the filter options to noise reduction processing is performed in order to optimize the video. Noise reduction process is a part of the video preprocessing, video encoding is generally complete prior to output.

denoising: noise reduction processing

Note: Sometimes there will be some granular or pictures on the video, obviously at some point does not belong to the original image, these points are called noise (represented causing interference to the real image), fall from the sky noise processing is to remove or blur the noise of these processes.

Video obfuscation

Noise appearing in images or video can be divided into a plurality of types, when the particular type of noise occurs, blurring processing can improve the picture quality. Fuzzy processing operation, each pixel value is calculated from the output of the same position as the input pixel value and its neighboring out. For example, we printed halftone images have been scanned their digital pictures, then you can use obfuscation to improve its quality. We use boxblur filter to obfuscate, a detailed description is as follows:

Here Insert Picture Description
luma: Brightness chroma: chroma alpha: transparency

r: radius, when the radius of the neighborhood represents a fuzzy operation, p: power represents the number of arithmetic operations Fuzzy

boxblur: In the OpenCV, called block or filter mean filter (when the filter block is equal to the normalized), is simply the pixels and which pixels are averaged art as an output value.

For example, to make a fuzzy input video processing, wherein luma radius is 1.5, luma power of 1, then the command is as follows:

ffmpeg -i input.mpg -vf boxblur=1.5:1 output.mp4

Another may do the blur effect is smartblur filter, details of which are as follows:

Here Insert Picture Description

r: radius of the Gaussian blur radius radius luminance color space, or space, ranging from 0.1 to 5.0

s: strength intensity, ranging from -1 to 0 when the output picture, sharpening operations -1 to 0, 0 to 1 fuzzy operation

t: treshold threshold, ranging from -30 to 30, 0 when the entire image filtering, smoothing region -30 to 0 filtered, 0-30 edge filter. Slow changes in the value of the pixels of the image area is smooth areas, dramatic changes are called marginal areas.

​ smartblur的特点是:模糊处理时,对边缘处不会有影响。

​ 例如,我们可以使用如下命令和参数对图片进行模糊处理:

ffmpeg -i halftone.jpg -vf smartblur=5:0.8:0 blurred_halftone.png

Here Insert Picture Description

视频锐化

​ 我们可以使用 unsharp filter 来锐化或者模糊视频帧,其详细描述如下:

Here Insert Picture Description

​ luma:亮度 chroma:色度

​ x:领域的宽度 y:领域的高度 amount:-2 ~ 5 ,负值时进行模糊操作,正值进行锐化,0时无影响

​ unarpen filter可以用作模糊掩码或者高斯模糊。例如,我们可以使用默认参数来锐化输入,命令如下:

ffmpeg -i input -vf unsharp output.mp4

​ 此时,对亮度的锐化操作会使用 5x5 大小的矩阵,其影响因子为 1.0 。而想要执行高斯模糊,我们可以对亮度和色度设置一个负值,例如:

ffmpeg -i input -vf unsharp=6:6:-2 output.mp4

​ 下面的图像分为四部分,分别表示使用 unsharp filter 在不同参数下的结果:

Here Insert Picture Description

  • 图1:输入图像,是NASA在2012年6月5日,金星经过太阳时拍摄到的图片,这是从NASA的网页上下载的。
  • 图2:使用 -vf unsharp(没有指定参数,使用默认参数)的结果。黑点变得更加明显,无明显影响
  • 图3:使用 -vf unsharp=6:6:3(相对较强的锐化处理)的结果。黑点变得更多,更明显,视觉有轻微的失真
  • 图4:使用 -vf unsharp=6:6:-2 (相对较强的模糊处理) 的结果。使用 -2 对亮度进行模糊处理,环绕金星出现了一个虚环。

使用 denoise3d 降低噪声

​ 视频过滤器 denoise3d 可以降低噪声,它是 mp filter 的一部分(来自 MPlayer 项目),其详细描述如下:

Here Insert Picture Description

​ spatial:空间 strength:强度 luma:亮度 chroma:色度 temporal:暂时的

​ 例如,如果要使用默认的参数对输入进行增强,那么可以使用命令:

ffmpeg -i input.mpg -vf mp=denoise3d output.webm

​ 下图显示了使用 denoise3d filter 增强的视频,该视频来自 NASA 阿波罗计划:

Here Insert Picture Description

使用 hqdn3d 降低噪声

Advanced version denoise3d filter is hqdn3d filter, place it in libavfilter, the FFmpeg is a built-in filter. The name is a high quality denoise 3-dimensional filter for short, which is detailed below:

Here Insert Picture Description

For example, using the default parameter value hqdn3d input video noise reduction, the command is as follows:

ffmpeg -i input.avi -vf hqdn3d output.mp4

The following figure shows the effect of using different view of hqdn3d parameters:

Here Insert Picture Description

Use nr option reduces noise

In addition to the filter, we can also use -nr (noise reduction) option to reduce the noise of the input video. Its value is an integer from 0 to 100,000, the default value is 0, for common content, its useful range is 1 to 600. If the video contains dense noise, then we should take a number of high value. Since this option denoise3d and hqdn3d, its consumption of computer resources compared to smaller, so when we need to quickly deal with the noise, you can use this option. For example, on an old computer, we use -nr improve relatively minor noise, you can use the command:

ffplay -i input.avi -nr 500

3d, its consumption of computer resources to be smaller, so when we need to quickly deal with the noise, you can use this option. For example, on an old computer, we use -nr improve relatively minor noise, you can use the command:

ffplay -i input.avi -nr 500

H&A
Released seven original articles · won praise 4 · Views 825

Guess you like

Origin blog.csdn.net/qq_34305316/article/details/103935713