utils/augment.py
def salt_img(self, img):
        """
           salt noise
           the number of sale dot is n
        """
        n = int(img.shape[0] * img.shape[1] * 0.001)
        ilist = np.random.randint(0, img.shape[1], n)
        jlist = np.random.randint(0, img.shape[0], n)
        for k in range(n):
            i = ilist[k]
            j = jlist[k]
            if img.ndim == 2:
                img[j, i] = 255
            elif img.ndim == 3:
                img[j:j + 1, i:i + 1, :] = 255
        return img

           salt noise
           the number of sale dot is n
        
salt noise
the number of sale dot is n
salt noise the number of sale dot is n
def salt_img(self, img):
        n = int(img.shape[0] * img.shape[1] * 0.001)
        ilist = np.random.randint(0, img.shape[1], n)
        jlist = np.random.randint(0, img.shape[0], n)
        for k in range(n):
            i = ilist[k]
            j = jlist[k]
            if img.ndim == 2:
                img[j, i] = 255
            elif img.ndim == 3:
                img[j:j + 1, i:i + 1, :] = 255
        return img
def salt_img ( self , img ) : n = int ( img . shape [ 0 ] * img . shape [ 1 ] * 0.001 ) ilist = np . random . randint ( 0 , img . shape [ 1 ] , n ) jlist = np . random . randint ( 0 , img . shape [ 0 ] , n ) for k in range ( n ) : i = ilist [ k ] j = jlist [ k ] if img . ndim == 2 : img [ j , i ] = 255 elif img . ndim == 3 : img [ j : j + 1 , i : i + 1 , : ] = 255 return img
salt noise
the number of sale dot is n
salt noise the number of sale dot is n
"""
           salt noise
           the number of sale dot is n
        """
self
img