Since entropy is a measure of uncertainty or randomness, intuitively we would suppose that adding noise to an image would increase its entropy since we are now more uncertain about the information of the image. I actually confirmed (partially) this assumption with the following MATLAB code where i noticed that when adding gaussian noise to a grayscale image, the entropy increases, whereas adding salt & pepper noise slightly decreases the entropy. Why is this happening and how does noise affect overall the Shannon entropy of an image?
This is my MATLAB code:
load('trees.mat'); RGB=ind2rgb(X,map); GRAY=rgb2gray(RGB); vecRGB=RGB(:); %--vector of RGB image vecGRAY=GRAY(:); %--vector of GRAYSCALE image HVECR=entropy(vecRGB); %--entropy of RGB image HVECG=entropy(vecGRAY); %--entropy of GRAYSCALE image GRAY_GAUSSIAN=imnoise(GRAY,'gaussian'); %--add gaussian noise to GRAYSCALE image GRAY_SALT=imnoise(GRAY,'salt & pepper'); %--add salt & pepper noise vec_GRAYG=GRAY_GAUSSIAN(:); %--vectorize image with gaussian noise vec_GRAYSP=GRAY_SALT(:); %--vectorize image with salt & pepper noise HVECGG=entropy(vec_GRAYG); %--entropy with gaussian noise HVECGSP=entropy(vec_GRAYSP); %--entropy with salt & pepper noise
And these are the entropies i got:
- Entropy of Grayscale Image (no noise)=5.4723
- Entropy of Grayscale Image (Gaussian Noise)=7.6948
- Entropy of Grayscale Image (Salt & Pepper Noise)=5.4380