Esempio n. 1
0
def test_imread_collection_single_MEF():
    io.use_plugin('fits')
    testfile = os.path.join(data_dir, 'multi.fits')
    ic1 = io.imread_collection(testfile)
    ic2 = io.ImageCollection([(testfile, 1), (testfile, 2), (testfile, 3)],
                             load_func=fplug.FITSFactory)
    assert _same_ImageCollection(ic1, ic2)
Esempio n. 2
0
def test_imread_collection_single_MEF():
    io.use_plugin('fits')
    testfile = os.path.join(data_dir, 'multi.fits')
    ic1 = io.imread_collection(testfile)
    ic2 = io.ImageCollection([(testfile, 1), (testfile, 2), (testfile, 3)],
              load_func=fplug.FITSFactory)
    assert _same_ImageCollection(ic1, ic2)
Esempio n. 3
0
def test_imread_collection_MEF_and_simple():
    io.use_plugin('fits')
    testfile1 = os.path.join(data_dir, 'multi.fits')
    testfile2 = os.path.join(data_dir, 'simple.fits')
    ic1 = io.imread_collection([testfile1, testfile2])
    ic2 = io.ImageCollection([(testfile1, 1), (testfile1, 2),
                             (testfile1, 3), (testfile2, 0)],
                             load_func=fplug.FITSFactory)
    assert _same_ImageCollection(ic1, ic2)
Esempio n. 4
0
def test_imread_collection_MEF_and_simple():
    io.use_plugin('fits')
    testfile1 = os.path.join(data_dir, 'multi.fits')
    testfile2 = os.path.join(data_dir, 'simple.fits')
    ic1 = io.imread_collection([testfile1, testfile2])
    ic2 = io.ImageCollection([(testfile1, 1), (testfile1, 2), (testfile1, 3),
                              (testfile2, 0)],
                             load_func=fplug.FITSFactory)
    assert _same_ImageCollection(ic1, ic2)
Esempio n. 5
0
def test_fits_plugin_import():
    # Make sure we get an import exception if PyFITS isn't there
    # (not sure how useful this is, but it ensures there isn't some other
    # error when trying to load the plugin)
    try:
        io.use_plugin('fits')
    except ImportError:
        assert pyfits_available == False
    else:
        assert pyfits_available == True
Esempio n. 6
0
def test_fits_plugin_import():
    # Make sure we get an import exception if PyFITS isn't there
    # (not sure how useful this is, but it ensures there isn't some other
    # error when trying to load the plugin)
    try:
        io.use_plugin('fits')
    except ImportError:
        assert pyfits_available == False
    else:
        assert pyfits_available == True
Esempio n. 7
0
def main():
    import scikits.image.io as io
    import sys

    if len(sys.argv) != 2:
        print "Usage: scivi <image-file>"
        sys.exit(-1)

    io.use_plugin("qt")
    io.imshow(io.imread(sys.argv[1]), fancy=True)
    io.show()
Esempio n. 8
0
def main():
    import scikits.image.io as io
    import sys

    if len(sys.argv) != 2:
        print "Usage: scivi <image-file>"
        sys.exit(-1)

    io.use_plugin('qt')
    io.imshow(io.imread(sys.argv[1]), fancy=True)
    io.show()
Esempio n. 9
0
def main():
    import scikits.image.io as io
    import sys

    if len(sys.argv) < 2:
        print "Usage: scivi <image-file> [<flip-file>]"
        sys.exit(-1)

    io.use_plugin('qt2')
    im = io.imread(sys.argv[1])
    flip = None
    if len(sys.argv) > 2:
        flip = io.imread(sys.argv[2])
    io.imshow(im, flip=flip, fancy=True)
    io.show()
Esempio n. 10
0
#!/usr/bin/env python
# From EPD webinar
#

import sys;

from itertools import izip;

import numpy as np;
import scipy.ndimage as ndi;
from PIL import Image,ImageDraw;
from scikits.image import io;

io.use_plugin('qt');

def hough(img,theta=None):
    """
    Apply a linear hough transform to the input image
    
    Input:
     - img    <ndarray>  : Thresholded input image (ndim=2,dtype=float)
     - theta  <ndarray>  : Angle range to search in trsnform space. (ndim=1,dtype=float)
                           If None, defaults to (-pi/2,pi/2)
    
    Output:
     - hough <ndarray>  : The hough transform coefficients (ndim=2,dtype=float)
     - dists <ndarray>  : Distance values (ndim=1,dtype=float)
     - theta <ndarray>  : Angle values (ndim=1,dtype=float)
    
    ---
    """
Esempio n. 11
0
import os.path
import numpy as np
from numpy.testing import *

from tempfile import NamedTemporaryFile

from scikits.image import data_dir
from scikits.image.io import imread, imsave, use_plugin
from scikits.image.io._plugins.pil_plugin import _palette_is_grayscale

use_plugin('pil')

def test_imread_flatten():
    # a color image is flattened
    img = imread(os.path.join(data_dir, 'color.png'), flatten=True)
    assert img.ndim == 2
    assert img.dtype == np.float64
    img = imread(os.path.join(data_dir, 'camera.png'), flatten=True)
    # check that flattening does not occur for an image that is grey already.
    assert np.sctype2char(img.dtype) in np.typecodes['AllInteger']

def test_imread_palette():
    img = imread(os.path.join(data_dir, 'palette_gray.png'))
    assert img.ndim == 2
    img = imread(os.path.join(data_dir, 'palette_color.png'))
    assert img.ndim == 3

def test_palette_is_gray():
    from PIL import Image
    gray = Image.open(os.path.join(data_dir, 'palette_gray.png'))
    assert _palette_is_grayscale(gray)
Esempio n. 12
0
def test_imread_simple():
    io.use_plugin('fits')
    testfile = os.path.join(data_dir, 'simple.fits')
    img = io.imread(testfile)
    assert np.all(img==pyfits.getdata(testfile, 0))
Esempio n. 13
0
import os.path
import numpy as np
from numpy.testing import *

from tempfile import NamedTemporaryFile

from scikits.image import data_dir
from scikits.image.io import imread, imsave, use_plugin
from scikits.image.io._plugins.pil_plugin import _palette_is_grayscale

use_plugin('pil')


def test_imread_flatten():
    # a color image is flattened
    img = imread(os.path.join(data_dir, 'color.png'), flatten=True)
    assert img.ndim == 2
    assert img.dtype == np.float64
    img = imread(os.path.join(data_dir, 'camera.png'), flatten=True)
    # check that flattening does not occur for an image that is grey already.
    assert np.sctype2char(img.dtype) in np.typecodes['AllInteger']


def test_imread_palette():
    img = imread(os.path.join(data_dir, 'palette_gray.png'))
    assert img.ndim == 2
    img = imread(os.path.join(data_dir, 'palette_color.png'))
    assert img.ndim == 3


def test_palette_is_gray():
Esempio n. 14
0
def test_imread_simple():
    io.use_plugin('fits')
    testfile = os.path.join(data_dir, 'simple.fits')
    img = io.imread(testfile)
    assert np.all(img == pyfits.getdata(testfile, 0))
Esempio n. 15
0
def test_imread_MEF():
    io.use_plugin('fits')
    testfile = os.path.join(data_dir, 'multi.fits')
    img = io.imread(testfile)
    assert np.all(img == pyfits.getdata(testfile, 1))
Esempio n. 16
0
import os

import scikits.image as si
import scikits.image.io as sio

sio.use_plugin('matplotlib', 'imshow')
sio.use_plugin('freeimage', 'imread')

img = sio.imread(os.path.join(si.data_dir, 'color.png'))

sio.imshow(img)
sio.show()

Esempio n. 17
0
def test_imread_MEF():
    io.use_plugin('fits')
    testfile = os.path.join(data_dir, 'multi.fits')
    img = io.imread(testfile)
    assert np.all(img==pyfits.getdata(testfile, 1))
Esempio n. 18
0
from numpy.testing import *

from scikits.image import io
from scikits.image.io._plugins import plugin
from numpy.testing.decorators import skipif

from copy import deepcopy

try:
    io.use_plugin('pil')
    PIL_available = True
    priority_plugin = 'pil'
except ImportError:
    PIL_available = False

try:
    io.use_plugin('freeimage')
    FI_available = True
    priority_plugin = 'freeimage'
except OSError:
    FI_available = False


def setup_module(self):
    self.backup_plugin_store = deepcopy(plugin.plugin_store)
    plugin.use('test') # see ../_plugins/test_plugin.py

def teardown_module(self):
    plugin.plugin_store = self.backup_plugin_store

class TestPlugin: