Skip to content
Snippets Groups Projects
Commit 43ae0d2d authored by Gustav Als's avatar Gustav Als
Browse files

Merge branch 'Prepocessing' of https://github.com/GustavAls/BachelorDeeplearning into Prepocessing

parents 2a5790c1 ae7b7dff
Branches
No related tags found
1 merge request!2Prepocessing
...@@ -5,20 +5,29 @@ from scipy import signal ...@@ -5,20 +5,29 @@ from scipy import signal
plt.close('all') plt.close('all')
def dilation33(image): def dilation33(image):
# Makes a 3 by 3 dilation of the a 2D image, program crashes if not provided as such # Makes a 3 by 3 dilation of the a 2d image, program crashes if not provided as such
y_height, x_height = image.shape y_height, x_height = image.shape
out_image = np.zeros(y_height,x_height,3) out_image = np.zeros((y_height,x_height,3))
out_image[:,:,0] = np.vstack(image[1:],image[-1])
out_image[:,:,0] = np.row_stack((image[1:,:],image[-1,:]))
out_image[:,:,1] = image out_image[:,:,1] = image
out_image[:,:,2] = np.vstack(image[0],image[0:y_height-1]) out_image[:,:,2] = np.row_stack((image[0,:],image[:(y_height-1),:]))
out_image2 = np.max(out_image, axis= 2) out_image2 = np.max(out_image, axis= 2)
out_image[:,:,0] = np.concatenate([image[:,1:],image[:,-1]],axis = 1) out_image[:,:,0] = np.column_stack(([image[:,1:],image[:,-1]]))
out_image[:,:,1] = out_image2 out_image[:,:,1] = out_image2
out_image[:,:,2] = np.concatenate([image[:,0],image[:,0:(x_height-1)]],axis = 1) out_image[:,:,2] = np.column_stack(([image[:,0],image[:,0:(x_height-1)]]))
out_image = np.max(out_image, axis=2) out_image = np.max(out_image, axis=2)
return out_image return out_image
test = np.random.normal(100,7, (50,50))
plt.figure(0)
plt.imshow(test)
test = dilation33(test)
plt.figure(1)
plt.imshow(test)
plt.show()
def fill_border(image, border_width): def fill_border(image, border_width):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment