官术网_书友最值得收藏!

Introduction to filters

Filters are operations on an image to modify them so that they are usable for other computer vision tasks or to give us required information. These perform various functions such as removing noise from an image, extracting edges in an image, blurring an image, removing unwanted objects etc. We will see their implementations and understand the results.

Filtering techniques are necessary because there are several factors that may lead to noise in an image or undesired information in an image. Taking a picture in sunlight, induces lots of bright and dark areas in the image or an improper environment like night time, the image captured by a camera may contain a lot of noise. Also, in cases of unwanted objects or colors in an image, these are also considered noise.

An example of salt and pepper noise looks like the following:

The preceding image can be easily generated using OpenCV as follows:

# initialize noise image with zeros
noise = np.zeros((400, 600))

# fill the image with random numbers in given range
cv2.randu(noise, 0, 256)

Let's add weighted noise to a grayscale image (on the left) so the resulting image will look like the one on the right:

The code for this is as follows:

# add noise to existing image 
noisy_gray = gray + np.array(0.2*noise, dtype=np.int)

Here, 0.2 is used as parameter, increase or decrease the value to create different intensity noise. 

In several applications, noise plays an important role in improving a system's capabilities, especially when we will use Deep Learning based models in the upcoming chapters. It is quite crucial for several applications, to know how robust the application is against noise becomes very important. As an example, we would want the model designed for applications like image classification to work with noisy images as well, hence noise is deliberately added in the images to test the application precision. 

主站蜘蛛池模板: 古交市| 香河县| 乌海市| 木兰县| 徐水县| 泗洪县| 玉林市| 桃园市| 长子县| 铜陵市| 白城市| 孝昌县| 聂荣县| 武清区| 锡林郭勒盟| 泽普县| 扶沟县| 通化市| 辽阳市| 达日县| 竹山县| 高碑店市| 五原县| 双城市| 莎车县| 太仓市| 绥德县| 西峡县| 苍南县| 泸定县| 大丰市| 丰都县| 抚松县| 长顺县| 呼伦贝尔市| 尼勒克县| 福泉市| 郴州市| 南京市| 台江县| 普兰县|