def visualize_go(): ''' Visualize the gradient orientation responses. ''' img = sp.misc.imread('data/patterns.png', flatten=True) go, go_m = gradient_orientation(img, 2.5, signed=True, fft=False) imsave('go/patterns-go.png', go) imsave('go/patterns-go_weighted.png', go*go_m) go, go_m = gradient_orientation(img, 2.5, signed=False, fft=False) imsave('go/patterns-go_unsigned.png', go)
def visualize_bif(): ''' Visualize the shape index responses. ''' img = sp.misc.imread('data/camera.png', flatten=True) bif_img = bif_colors(bif_response(img, 2, eps=0.02)) imsave('bif/lena-bif-sigma2.png', bif_img) bif_img = bif_colors(bif_response(img, 4, eps=0.02)) imsave('bif/lena-bif-sigma4.png', bif_img) bif_img = bif_colors(bif_response(img, 8, eps=0.02)) imsave('bif/lena-bif-sigma8.png', bif_img)
def visualize_si_fiducial_orientation(): ''' Visualize the shape index orientation with a fiducial coordinate system.''' img = sp.misc.imread('data/rings.png', flatten=True) si, si_c, si_o, si_om = shape_index(img, 2.5, orientations=True, fft=True) # No fiducial coordinate system. imsave('si/rings-si_o.png', si_o) imsave('si/rings-si_o_weighted.png', si_o * si_om) # Let each pixel have its own coordinate system where the origin is # the image center and the first axis is the vector from the origin to # the pixel. h, w = img.shape[:2] y = np.linspace(-h / 2., h / 2., h) x = np.linspace(-w / 2., w / 2., w) xv, yv = np.meshgrid(x, y) offsets = np.arctan(yv / (xv + 1e-10)) si_o = np.mod(si_o + offsets, np.pi) imsave('si/rings-si_o_fiducial.png', si_o) imsave('si/rings-si_o_fiducial_weighted.png', si_o * si_om)
def visualize_si_fiducial_orientation(): ''' Visualize the shape index orientation with a fiducial coordinate system.''' img = sp.misc.imread('data/rings.png', flatten=True) si, si_c, si_o, si_om = shape_index(img, 2.5, orientations=True, fft=True) # No fiducial coordinate system. imsave('si/rings-si_o.png', si_o) imsave('si/rings-si_o_weighted.png', si_o*si_om) # Let each pixel have its own coordinate system where the origin is # the image center and the first axis is the vector from the origin to # the pixel. h, w = img.shape[:2] y = np.linspace(-h/2., h/2., h) x = np.linspace(-w/2., w/2., w) xv, yv = np.meshgrid(x, y) offsets = np.arctan(yv/(xv+1e-10)) si_o = np.mod(si_o+offsets, np.pi) imsave('si/rings-si_o_fiducial.png', si_o) imsave('si/rings-si_o_fiducial_weighted.png', si_o*si_om)
def visualize(): ''' Visualize the shape index responses. ''' img = sp.misc.imread('data/patterns.png', flatten=True) go, go_m = gradient_orientation(img, 3) iso_go = isophotes(go, 5, (-np.pi, np.pi), .5, 'gaussian') imsave('isophotes/patterns-go.png', go*go_m) for i in range(iso_go.shape[0]): imsave('isophotes/patterns-go_iso_%i_gaussian.png'%i, iso_go[i, ...]*go_m) iso_go = isophotes(go, 5, (-np.pi, np.pi), .5, 'von_mises') for i in range(iso_go.shape[0]): imsave('isophotes/patterns-go_iso_%i_von_mises.png'%i, iso_go[i, ...]*go_m)
def visualize(): ''' Visualize the shape index responses. ''' img = sp.misc.imread('data/patterns.png', flatten=True) go, go_m = gradient_orientation(img, 3) iso_go = isophotes(go, 5, (-np.pi, np.pi), .5, 'gaussian') imsave('isophotes/patterns-go.png', go * go_m) for i in range(iso_go.shape[0]): imsave('isophotes/patterns-go_iso_%i_gaussian.png' % i, iso_go[i, ...] * go_m) iso_go = isophotes(go, 5, (-np.pi, np.pi), .5, 'von_mises') for i in range(iso_go.shape[0]): imsave('isophotes/patterns-go_iso_%i_von_mises.png' % i, iso_go[i, ...] * go_m)
def visualize_go_fiducial_orientation(): ''' Visualize the shape index orientation with a fiducial coordinate system.''' img = sp.misc.imread('data/rings.png', flatten=True) go, go_m = gradient_orientation(img, 2.5, signed=True, fft=False) # No fiducial coordinate system. imsave('go/rings-go.png', go) # Let each pixel have its own coordinate system where the origin is # the image center and the first axis is the vector from the origin to # the pixel. h, w = img.shape[:2] y = np.linspace(-h/2., h/2., h) x = np.linspace(-w/2., w/2., w) xv, yv = np.meshgrid(x, y) offsets = np.arctan2(yv, xv) go = np.mod(go-offsets, 2*np.pi) imsave('go/rings-go-fiducial.png', go) imsave('go/rings-go-fiducial_weighted.png', go*go_m)
def visualize_donuts(): ''' Visualize donut spatial weighs. ''' ds = donuts((100, 100), 3, 30, 8.0, 1.2) for i, d in enumerate(ds): imsave('donuts/donut%i.png'%i, d)
def visualize_si(): ''' Visualize the shape index responses. ''' img = sp.misc.imread('data/patterns.png', flatten=True) si, si_c, si_o, si_om = shape_index(img, 2.5, orientations=True, fft=True) imsave('si/patterns-si.png', si) imsave('si/patterns-si_c.png', si_c) imsave('si/patterns-si_weighted.png', si * si_c) imsave('si/patterns-si_o.png', si_o) imsave('si/patterns-si_om.png', si_om) imsave('si/patterns-si_o_weighted.png', si_o * si_om)
def visualize_donuts(): ''' Visualize donut spatial weighs. ''' ds = donuts((100, 100), 3, 30, 8.0, 1.2) for i, d in enumerate(ds): imsave('donuts/donut%i.png' % i, d)
def visualize_si(): ''' Visualize the shape index responses. ''' img = sp.misc.imread('data/patterns.png', flatten=True) si, si_c, si_o, si_om = shape_index(img, 2.5, orientations=True, fft=True) imsave('si/patterns-si.png', si) imsave('si/patterns-si_c.png', si_c) imsave('si/patterns-si_weighted.png', si*si_c) imsave('si/patterns-si_o.png', si_o) imsave('si/patterns-si_om.png', si_om) imsave('si/patterns-si_o_weighted.png', si_o*si_om)