I am implementing a paper on image segmentation in pytorch. I am required to do some preprocessing steps but as I am trying it the first time so I am unable to incorporate them in the traditional pipeline.
Following are the preprocessing steps-
1) N(w, h) = I(w, h) − G(w, h), (1) where N is the normalized image, I is the original image, and G is the Gaussian blurred image with kernel size 65*65 and 0 mean and standard deviation 10.
2)Normalizing the mean image and dividing each pixel by average standard deviation.
Following is my code snippet for the above steps-
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
I am really not sure how to add above functions in the traditional pytorch data-loaders pipeline like first I should load the dataset using ImageFolder
and then apply or first apply and then use ImageFolder
method.