Exemplo n.º 1
0
def check(tilt, img0, img180):
    """check tilt using a pair of images
    """
    from imars3d import io
    apply(tilt, img0, io.ImageFile("tilted-0.npy"))
    apply(tilt, img180, io.ImageFile("tilted-180.npy"))
    return
Exemplo n.º 2
0
def getEdge(imgpath, edgepath, **kwds):
    img = io.ImageFile(imgpath).data
    edge = feature.canny(img, **kwds)
    edge = np.array(edge, dtype="float32")
    edgeimg = io.ImageFile(path=edgepath)
    edgeimg.data = edge
    edgeimg.save()
    return edge
Exemplo n.º 3
0
def _test_ext(ext):
    data = np.arange(300 * 400, dtype="float32")
    data.shape = 300, 400
    imgfile = io.ImageFile("img1.%s" % ext)
    imgfile.data = data
    imgfile.save()
    data2 = io.ImageFile("img1.%s" % ext).data
    assert ((data == data2).all())
    return
Exemplo n.º 4
0
def main():
    img0 = os.path.join(datadir, 'injectorG/normalized_000.000.tiff')
    img180 = os.path.join(datadir, 'injectorG/normalized_180.000.tiff')
    img0 = io.ImageFile(img0)
    img180 = io.ImageFile(img180)
    from imars3d.tilt.use_centers import computeTilt
    computeTilt(img0,
                img180,
                workdir="_tmp.use_centers",
                sigma=3,
                maxshift=200)
    return
Exemplo n.º 5
0
def test():
    from skimage import feature
    from imars3d import io
    dir = os.path.dirname(__file__)
    datadir = os.path.join(dir, "..", "..", 'iMars3D_data_set')
    imgpath = os.path.join(datadir, 'injectorG/normalized_000.000.tiff')
    img = io.ImageFile(imgpath).data
    edge = feature.canny(img, sigma=3)
    edge = np.array(edge, dtype="float32")
    edgeimg = io.ImageFile(path="edge_sigma3.tiff")
    edgeimg.data = edge
    edgeimg.save()
    return
def test(interactive=False):
    # test data
    dir = os.path.dirname(__file__)
    path = os.path.join(dir, "..", "..", "iMars3D_data_set",
                        "20120618_TURBINECT_0180_46_750_0055.fits")
    img = io.ImageFile(path).getData()
    assert img.dtype == np.dtype('uint16')
    # force a pixel to be an outlier
    img[0, 0] = (1 << 16) - 1
    # filter
    orig_max = np.max(img)
    img = filters.gamma_filtering.filter_one(img)
    new_max = np.max(img)
    assert new_max < orig_max

    if interactive:
        # display
        import pylab
        pylab.imshow(img)
        pylab.colorbar()
        pylab.show()
Exemplo n.º 7
0
def test_computeTilt():
    img0 = io.ImageFile(os.path.join(datadir, "smoothed_000.000.tiff")).data
    img180 = io.ImageFile(os.path.join(datadir, "smoothed_180.200.tiff")).data
    t = direct.computeTilt(img0, img180)
    assert t > -2 and t < -1
    return
Exemplo n.º 8
0
def test_shift():
    img0 = io.ImageFile(os.path.join(datadir, "cropped_000.000.tiff")).data
    img180 = io.ImageFile(os.path.join(datadir, "cropped_180.000.tiff")).data
    flipped_180 = np.fliplr(img180)
    assert np.isclose(direct.findShift(img0, flipped_180), -78)
    return
Exemplo n.º 9
0
def test_computeTilt():
    img0 = io.ImageFile(os.path.join(datadir, "cropped_000.000.tiff")).data
    img180 = io.ImageFile(os.path.join(datadir, "cropped_180.000.tiff")).data
    assert np.isclose(direct.computeTilt(img0, img180), 0.4)
    return
Exemplo n.º 10
0
import os
import numpy as np
import matplotlib.pyplot as plt

from imars3d import config, io
from imars3d import detector_correction


file = './tests/iMars3D_data_set/Low_res_Gdmask_r0000.fits'
#print('Does file exist: %s' %os.path.isfile(file))

# retrieve image
image_data = io.ImageFile(file).getData()

#plt.figure(1)
#plt.title("Before")
#plt.imshow(image_data, cmap='gray')
#plt.colorbar()
#plt.show()

(detector_width, detector_height) = image_data.shape
chip_width = int(detector_width/2)
chip_height = int(detector_height/2)

# isolate chips data
chip1 = image_data[0:chip_height, 0:chip_width]
chip2 = image_data[0:chip_height, chip_width:detector_width]
chip3 = image_data[chip_height:detector_height, 0:chip_width]
chip4 = image_data[chip_height:detector_height, chip_width:detector_width]

# init final image
Exemplo n.º 11
0
def test_filter_one():
    newimg = io.ImageFile('ifced.tiff')
    newimg.data = ifc.filter_one(img.data, sigma=3)
    newimg.save()
    return
Exemplo n.º 12
0
#!/usr/bin/env python

import os, numpy as np
from imars3d.filters import ifc

from imars3d import io

dir = os.path.dirname(__file__)
datadir = os.path.join(dir, "..", "..", "..", 'iMars3D_data_set')
imgpath = os.path.join(datadir, 'injectorG/normalized_000.000.tiff')
img = io.ImageFile(imgpath)


def test_getBoundary():
    ifc.getBoundary(img.data, sigma=3, debug=True)
    return


def test_getBG():
    print(ifc.getBG(img.data, sigma=3, debug=True))
    return


def test_filter_one():
    newimg = io.ImageFile('ifced.tiff')
    newimg.data = ifc.filter_one(img.data, sigma=3)
    newimg.save()
    return


def main():