Example #1
0
def test_gaussImage():
    for scale in range(getScales()):
        a = np.zeros((400,700), dtype=np.float32)
        a[200,:] = 1.0
        a[:,200] = 1.0
        for xy in range(400):
            a[xy,xy] = 1.0
        b = gaussImage(a, scale)
        showArray("GI%s" % scale, b)
Example #2
0
def test_zcs():
    from utils import showArray
    from gaussian import gaussImage
    image = np.zeros((512,512), dtype=np.float32)
    image[255,255] = 1.0
    smaller = gaussImage(image, 2)
    larger = gaussImage(image, 3)
    dog = smaller-larger
    zca = zcs(dog)
    showArray("smaller", smaller)
    showArray("larger", larger)
    showArray("dog", dog)
    showArray("zca", zca)
Example #3
0
def test_zcs():
    import time
    for res in (False, True):
        subtotal = 0.0
        for scale in range(getScales()-1):
            a = np.zeros((1200,1800), dtype=np.float32)
            a[200,:] = 1.0
            a[:,200] = 1.0
            t = time.time()
            zca,grad,theta = zcsdog(a,scale)
            subtotal += (time.time()-t)
            showArray("org %s" % scale, a)
            showArray("zcs %s" % scale, zca)
            showArray("grad %s" % scale, grad)
            showArray("theta %s" % scale, theta)
        print "Res", res, "seconds", subtotal
Example #4
0
program = kernels.loadProgram(interfaces.hsi)

def rgb2hsi(r, g, b):
    h, s, i, trace = program.rgb2hsi(r, g, b) #@UnusedVariable
    return h, s, i

def hsi2rgb(h, s, i):
    r,g,b = program.hsi2rgb(h,s,i)
    return r,g,b
if __name__ == "__main__":
    from utils import showArray
    r = np.empty((256, 256), dtype=np.float32)
    g = np.empty_like(r)
    b = np.empty_like(r)
    for i in range(256):
        r[i, :] = i
        g[:, i] = i
        b[i, :] = 255 - i
    rgb = joinChannels(r, g, b)
    rgb /= 255.0
    showArray("Test data", rgb)
    rgb2 = joinChannels(*splitChannels(rgb))
    showArray("Test split and join", rgb2)
    h, s, i = rgb2hsi(*splitChannels(rgb))
    showArray("I", i)
    showArray("H", h)
    showArray("S", s)
    print program

Example #5
0
import numpy as np
from rpc import kernels, interfaces
from utils import showArray
xy = kernels.loadProgram(interfaces.xy)
a = np.zeros((402,798),dtype=np.int32)
addr,x,y,label = xy.addr(a)
showArray("addr",addr)
showArray("x",x)
showArray("y", y)
showArray("label", label)
Example #6
0
 def saveImage(self, session, f):
     return showArray(displayPatches(self.getD(session), color=self.color),
                      f)
Example #7
0
def test():
    from median import median3x3
    from gradient import gradient
    from hsi import rgb2hsi, hsi2rgb, joinChannels, splitChannels
    
    # Create a noisy image with an embedded white square
    image = np.zeros((201,199),dtype=np.float32)
    width,height = image.shape
    x,y = width/2, height/2
    offset = 10
    image[x-offset:x+offset,y-offset:y+offset] = 2
    image += np.random.random_sample(image.shape)
    
    filtered = median3x3(image, 100)

    showArray("Noisy",image)
    showArray("Filtered",filtered)
    
    image = np.float32(imread("test.jpg"))
    image /= 256.

    showArray("Test HSI",image)
    r,g,b = splitChannels(image)
    h,s,i = rgb2hsi(r,g,b)
    showArray("I",i)
    showArray("S",s)
    showArray("H",h)

    from gaussian import gaussImage
    blur = gaussImage(i, 3)
    showArray("Blur", blur)
    blurmore = gaussImage(i,4)
    dog = blur-blurmore
    showArray("DOG", dog)
    
    g,a = gradient(i,5)
    showArray("Gradient",g)
    showArray("Angle", a)
    sat = np.ones_like(i)
    gimg = joinChannels(*hsi2rgb(a,sat,g))
    showArray("Color gradient with angle", gimg)
    showArrayGrad("Grad angle", image, a)
    showArrayGrad("Grad vectors", image, a,g*10)