In order to access each individual element of a matrix, you just need to specify its row and column numbers. The corresponding element will be returned, which can be a single numerical value or a vector of values in the case of a multichannel image.
Accessing pixel values
Getting ready
To illustrate the direct access to pixel values, we will create a simple function that adds salt-and-pepper noise to an image. As the name suggests, salt-and-pepper noise is a particular type of noise in which some randomly selected pixels are replaced by a white or a black pixel. This type of noise can occur in faulty communications when the value of some pixels is lost during the transmission. In our case, we will simply randomly select a...