Adding Noise To An Image With OpenCV
As a fun little project, let's try and add a little noise to an image. In particular, let's try adding something called salt-and-pepper noise to an image. So what is salt and pepper noise?Basically, we take an image, select a random pixel and convert it to a black or white pixel. For example, the white grainy image shown to the right is a "noisy" version of the one above it. So, how did I do this? First, I took the dimensions of the sample image that I wished to process. Then, we can think of the entire image as a 2-D array and each pixel can be located using $(i,j)$, where $i$ = position along the row and $j$ = position along the column. For example, the third pixel from the left, two rows down, would be $(2,1)$. Great! Now we have a system for pointing to a particular pixel in the image. So how do we take a random pixel? Here’s the interesting thing. Suppose you take a constant $a$ and a variable number $b$. Then, suppose we did $b$%$a$($b$ modulo $a$). ...