A recent article on data enhancement is more interesting: here is the core code implementation and implementation details, which can be accessed by itself:
Training neural Networks with Very Little data–a
The general meaning of the article is to transform the Cartesian coordinate system into the image in polar coordinate system through some transformation, which is directly given by the following formula:
The transformation is simple, the formula is also written clearly, according to the formula to implement the code:
GitHub
Https://github.com/zhly0/radial-transform
From skimage import data from skimage import IO import numpy as NP import math import Matplotlib.pyplot as Plt def To_gra
Y (img): w, h,_ = img.shape ret = Np.empty (W, h), dtype=np.uint8) RETF = Np.empty ((w, h), dtype=np.float) IMGF = Img.astype (float) retf[:,:] = (imgf[:,:, 1] + imgf[:,:, 2] + imgf[:,:, 0])/3) ret = Retf.astype (Np.uin
T8 return ret def radia_transform (img,w,h): shape = Im.shape new_im = Np.zeros (shape) print (SHAPE) Print (len) print (' W ', W) print (' H ', h) width = shape[1] height = shape[0] Lens = Len (shape) F or I in range (0,width): Xita = 2*3.14159*i/width to A in range (0,height): x = (int) (Math.floo R (A * Math.Cos (Xita))) y = (int) (Math.floor (A * Math.sin (Xita))) new_y = (int) (h+x) NE w_x = (int) (w+y) #print (h.dtype) if new_x>=0 and New_x<width:if new_y>=0
and New_y
and the corresponding transformations: