Irfanview
Inkscape
from skimage.io import imread, imsave
img = imread('./input/alcatraz.png')
img = img #conversion code here
imsave('./output/alcatraz.png', img)
from os import listdir
from skimage.io import imread, imsave
for image in listdir('./input'):
image = './input/' + image
print image
img = imread(image)
print img
sN = image.replace('input', 'output')
print sN
imsave(sN, img)
Is It Working?
from skimage.io import imread, imsave
#NOTE: img is a numpy array
img = imread('./input/alcatraz.png')
#Numpy Slicing Syntax
r = img[:,:,0]
g = img[:,:,1]
b = img[:,:,2]
imsave('./output/red_as_grey.png', r)
imsave('./output/green_as_grey.png', g)
imsave('./output/blue_as_grey.png', b)
Grayscale Color Layers
from skimage.io import imread, imsave
import numpy as np
#NOTE: img is a numpy array
img = imread('./input/alcatraz.png')
#Numpy Slicing Syntax
r = img[:,:,0]
g = img[:,:,1]
b = img[:,:,2]
#Create a matching array of zeroes
z = np.zeros_like(r)
#Reconstructing a three layer (R,G,B) img
red = np.dstack((r, z, z))
green = np.dstack((z, g, z))
blue = np.dstack((z, z, b))
imsave('./output/red_layer.png', red)
imsave('./output/green_layer.png', green)
imsave('./output/blue_layer.png', blue)
print r == g
print img.shape
Color Layers
from skimage.io import imread, imsave
import numpy as np
img = imread('./input/alcatraz.png', as_grey=True)
print 'Grayscale'
print img
#Equal to * 1 below
img = np.array(255 * img, dtype=int)
img_list = []
for n in [1, 2, 3, 5]:
img = img * n
print '\n\nimg * %d' % n
print img
#create the color img array
z = np.zeros_like(img)
g = np.dstack((z, img, z))
img_list.append(img)
imsave('./output/green_squared_%d.png' % n, g)
coolness = np.dstack(img_list[1:])
imsave('./output/coolness.png', coolness)
Filter Effect Output
Coolness!
from skimage.io import imread, imsave
import numpy as np
def image_crack_demo_grey(image='./input/alcatraz.png',
sN='./output/alcatraz.png',
factors=(2,3,5)):
'''Grayscale 'coolness' effect applied to passed image file.
factors are amount (r,g,b) color layers are multiplied by'''
img = np.array(255 * imread(image, as_grey=True), dtype=int)
r = img * factors[0]
g = img * factors[1]
b = img * factors[2]
imsave(sN, np.dstack((r,g,b)))
def image_crack_demo(image='./input/alcatraz.png',
sN='./output/alcatraz.png',
factors=(2,3,5)):
'''Color Layer 'coolness' effect applied to passed image file.
factors are amount (r,g,b) color layers are multiplied by'''
img = imread(image)
img[:,:,0] *= factors[0]
img[:,:,1] *= factors[1]
img[:,:,2] *= factors[2]
imsave(sN, img)
def run_image_demo():
'''Demo run of grayscale and color image_crack_demo
used to populate grand finale of webpage.'''
for factors in [(2,3,5), (5,3,2), (2,6,30), (30,6,2)]:
grey_sN = './output/alcatraz_%d_%d_%d_grey.png' % factors
image_crack_demo_grey(sN=grey_sN, factors=factors)
color_sN = './output/alcatraz_%d_%d_%d_color.png' % factors
image_crack_demo(sN=color_sN, factors=factors)
run_image_demo()
from skimage.io import imread, imsave
from skimage.filter.rank.generic import entropy
from skimage.filter import sobel
from skimage.morphology import disk
Replacing one liners for img = img
from scipy.signal import resample
from scipy.io.wavfile import read, write
r, d = read(wav_file_in)