Exemplo n.º 1
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)
Exemplo n.º 2
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)