I am implementing a research paper on image segmentation. Following are the image segmentation steps which are to be done before training its network-

1.Following image normalization is used-

N(w, h) = I(w, h) − G(w, h),<br>

where G is the gaussian blur image with std dev = 60 and kernel size = 65*65 and I is the original image.
2. The images are normalized by subtracting the mean image computed over the training set, and dividing each pixel by the average standard deviation.
3. A validation split of 15% is selected.
4.Random crops of size 512 × 512 are extracted randomly out of the original images ,We opt for a dynamic augmented data set, where training samples are generated randomly at the start of each mini-batch.
5. We artificially grow our data set by a factor of 8 through rotation at 90, 180 and 270 degrees and horizontal flips.
6. We have implemented elastic deformation by sampling control points on a regularly spaced 100 × 100 grid. Each control point has isotropic Gaussian noise added with σ = 20

Following is my implementation of the same-

def gaussian_blur(img):
    image = cv2.GaussianBlur(image,(65,65),10)
    new_image = img - image
return image

def normalise(img):
   img_normalised = np.empty(img.shape)
   img_std = np.std(img)
   img_mean = np.mean(img)
   img_normalized = (img-img_mean)/imgs_std

   for i in range(img.shape[1]):
      img_normalized[i] = (img_normalized - np.mean(img_normalized))/np.std(img_normalized)
   return img_normalized

path_dir = 'dataset_path'
data_transform = transforms.Compose([transforms.RandomCrop((512,512)),

dataset = datasets.ImageFolder(path_dir,transform = data_transform)

and I am loading it in the standard way using torch.dataloader after splitting it using randomSampler.

I am unable to figure out few things-
How to add normalization and gaussian_blur steps into it?
Am I doing the step 5th correctly?
How to implement elastic deformation step?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.