def test_numpy_serialiser():
    #create image
    data = array(range(30000)).reshape((100, 300))

    pal = rainbow(30000)

    img = pal[data]

    sp = SpatialImage(img, (0.5, 0.6), vdim=3)

    #save
    save("00_data", data)
    save("00_img", img, is_vectorial=True)
    save("00_sp", sp, is_vectorial=True)

    #load
    rdata = load("00_data.npy")
    rimg = load("00_img.npy")
    rsp = load("00_sp.npy")

    # -- save will promote everything to 3D --
    assert (rdata[:, :, 0] == data).all()
    assert (rimg[:, :, 0] == img).all()
    assert (rsp[:, :, 0] == sp).all()

    assert hasattr(rsp, "resolution")
    assert rsp.resolution[:2] == sp.resolution
    assert hasattr(rsp, "info")
def test_numpy_serialiser():
    #create image
    data = array(range(30000) ).reshape( (100,300) )

    pal = rainbow(30000)

    img = pal[data]

    sp = SpatialImage(img,(0.5,0.6),vdim = 3)

    #save
    save("00_data",data)
    save("00_img",img, is_vectorial=True)
    save("00_sp",sp, is_vectorial=True)

    #load
    rdata = load("00_data.npy")
    rimg  = load("00_img.npy")
    rsp   = load("00_sp.npy")

    # -- save will promote everything to 3D --
    assert (rdata[:,:,0] == data).all()
    assert (rimg[:,:,0] == img).all()
    assert (rsp[:,:,0] == sp).all()

    assert hasattr(rsp,"resolution")
    assert rsp.resolution[:2] == sp.resolution
    assert hasattr(rsp,"info")
Test frame manipulator
"""

__license__ = "Cecill-C"
__revision__ = " $Id: __init__.py 2245 2010-02-08 17:11:34Z cokelaer $ "

from openalea.vpltk.qt import QtGui
from openalea.image.all import rainbow, grayscale, to_pix
from numpy import array, apply_along_axis

qapp = QtGui.QApplication.instance()

if qapp:
    data = array(range(10000)).reshape((100, 100))

    pal = rainbow(10000)

    img = pal[data]

    def func(pix):
        if pix[0] > 100:
            return (0, 0, 0)
        else:
            return (255, 255, 255)

    img = apply_along_axis(func, -1, img)

    pix = to_pix(img)

    w = QtGui.QLabel()
    w.setPixmap(pix)
__license__= "Cecill-C"
__revision__ = " $Id: __init__.py 2245 2010-02-08 17:11:34Z cokelaer $ "

from numpy import array, random, zeros
from openalea.vpltk.qt import QtGui
from openalea.image.all import (rainbow,grayscale,bw,
				apply_mask,saturate,high_level,color_select, to_pix)

qapp = QtGui.QApplication.instance()

if qapp:

	#create image
	data = array(range(30000) ).reshape( (100,300) )

	pal = rainbow(30000)

	img = pal[data]

	img[:,:150,:] = img[:,:150,:] / 10

	#saturate
	sat = saturate(img)

	#high_level
	mask = high_level(img,100)
	pal = bw()
	hg = pal[mask * 1]
	hgimg = apply_mask(img,mask)

	#color_select
Test frame manipulator
"""

__license__= "Cecill-C"
__revision__ = " $Id: __init__.py 2245 2010-02-08 17:11:34Z cokelaer $ "

from openalea.vpltk.qt import QtGui
from openalea.image.all import rainbow,grayscale, to_pix
from numpy import array,apply_along_axis

qapp = QtGui.QApplication.instance()

if qapp:
	data = array(range(10000) ).reshape( (100,100) )

	pal = rainbow(10000)

	img = pal[data]

	def func (pix) :
		if pix[0] > 100 :
			return (0,0,0)
		else :
			return (255,255,255)

	img = apply_along_axis(func,-1,img)



	pix = to_pix(img)
#       OpenAlea WebSite : http://openalea.gforge.inria.fr
#
"""
Test frame manipulator
"""

__license__= "Cecill-C"
__revision__ = " $Id: __init__.py 2245 2010-02-08 17:11:34Z cokelaer $ "

from openalea.vpltk.qt import QtGui
from openalea.image.all import rainbow, FrameAnimator

qapp = QtGui.QApplication.instance()

if qapp:
	pal = rainbow(99)

	frames = []

	for i in xrange(100) :
		pix = QtGui.QPixmap(300,200)
		pix.fill(QtGui.QColor(*tuple(pal[i]) ) )
		frames.append(pix)

	w = FrameAnimator()
	w.set_frames(frames)

	w.show()


__license__ = "Cecill-C"
__revision__ = " $Id: __init__.py 2245 2010-02-08 17:11:34Z cokelaer $ "

from numpy import array, random, zeros
from openalea.vpltk.qt import QtGui
from openalea.image.all import (rainbow, grayscale, bw, apply_mask, saturate,
                                high_level, color_select, to_pix)

qapp = QtGui.QApplication.instance()

if qapp:

    #create image
    data = array(range(30000)).reshape((100, 300))

    pal = rainbow(30000)

    img = pal[data]

    img[:, :150, :] = img[:, :150, :] / 10

    #saturate
    sat = saturate(img)

    #high_level
    mask = high_level(img, 100)
    pal = bw()
    hg = pal[mask * 1]
    hgimg = apply_mask(img, mask)

    #color_select