Skip to content

Instantly share code, notes, and snippets.

View ChamodDamitha's full-sized avatar

Chamod Damitha Samarajeewa ChamodDamitha

  • La Trobe University
  • Melbourne, Australia
View GitHub Profile
from itertools import permutations
def generateNeighbours(point):
perm = set(permutations([-1, -1, -1, 0, 0, 1, 1, 1], 3))
return [(point[0] + p[0], point[1] + p[1], point[2] + p[2]) for p in perm]
def distance(a, b):
return (a[0] - b[0])**2 + (a[1] - b[1])**2 + (a[2] - b[2])**2
import os
from shutil import copyfile
types = []
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
ext = f.split('.')[-1]
dirr = 'Chategorized/' + ext + "-files"
if ext not in types:
from PIL import Image, ImageFilter
def getNeighbours(i, j, n, m) :
arr = []
if i-1 >= 0 and j-1 >= 0 :
arr.append((i-1, j-1))
if i-1 >= 0 :
arr.append((i-1, j))
if i-1 >= 0 and j+1 < m :
arr.append((i-1, j+1))