Created
December 14, 2016 12:55
-
-
Save AxelStrem/7ec6052d1cc5ad1485eee498c4e0f619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import prepare_img2 | |
import skimage.io as io | |
import PIL | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from skimage.color import rgb2gray | |
from skimage import data | |
from skimage.filters import gaussian | |
from skimage.segmentation import active_contour | |
from scipy.ndimage.filters import gaussian_filter | |
from skimage.draw import line | |
# Test scipy version, since active contour is only possible | |
# with recent scipy version | |
import scipy | |
scipy_version = list(map(int, scipy.__version__.split('.'))) | |
new_scipy = scipy_version[0] > 0 or \ | |
(scipy_version[0] == 0 and scipy_version[1] >= 14) | |
#img = data.astronaut() | |
img = io.imread('border.bmp') | |
out = np.zeros([img.shape[0]*3,img.shape[1]*3], dtype=np.int) | |
#print(out) | |
for x in range(1,img.shape[0]-1): | |
for y in range(1,img.shape[1]-1): | |
out[x*3:(x+1)*3,y*3:(y+1)*3] = img[x-1:x+2,y-1:y+2]*0.5+img[x,y]*0.5 | |
#out = gaussian_filter(out,1) | |
for x in range(0,out.shape[0]): | |
for y in range(0,out.shape[1]): | |
out[x,y] = int(np.rint(out[x,y]/255.0)*255) | |
io.imsave('border_processed.bmp',out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment