code: def spnoise(s, frc, smn=0.0, smx=1.0):
      
  
      sn = s.copy()
      spm = np.random.uniform(-1.0, 1.0, s.shape)
      sn[spm < frc - 1.0] = smn
      sn[spm > 1.0 - frc] = smx
      return sn
docs: Return image with salt & pepper noise imposed on it.
  
      Parameters
      ----------
      s : ndarray
        Input image
      frc : float
        Desired fraction of pixels corrupted by noise
      smn : float, optional (default 0.0)
        Lower value for noise (pepper)
      smx : float, optional (default 1.0)
        Upper value for noise (salt)
  
      Returns
      -------
      sn : ndarray
        Noisy image