示例#1
0
def test_binned_outlier(mask_method):
    b = map_to_binner(*generate_map_bin(geo, (2048, 2048)))
    img = np.ones((2048, 2048))
    bad = np.unique(np.random.randint(0, 2048 * 2048, 1000))
    urbad = np.unravel_index(bad, (2048, 2048))
    img[urbad] = 100
    mask = binned_outlier(img, b, mask_method=mask_method)

    assert_equal(np.where(mask.ravel() == 0)[0], bad)
示例#2
0
def test_z_score_image():
    b = map_to_binner(*generate_map_bin(geo, (2048, 2048)))
    img = np.ones((2048, 2048))
    bad = np.unique(np.random.randint(0, 2048 * 2048, 1000))
    urbad = np.unravel_index(bad, (2048, 2048))
    img[urbad] = 10

    z_score = z_score_image(img, b)
    assert all(z_score[urbad] > 2)
示例#3
0
def test_mask_img(mask_method):
    b = map_to_binner(*generate_map_bin(geo, (2048, 2048)))
    img = np.ones((2048, 2048))
    r = np.random.RandomState(42)
    bad = np.unique(r.randint(0, 2048 * 2048, 1000))
    urbad = np.unravel_index(bad, (2048, 2048))
    img[urbad] = 10
    mask = mask_img(
        img,
        b,
        auto_type=mask_method,
        edge=None,
        lower_thresh=None,
        upper_thresh=None,
    )

    assert_equal(np.where(mask.ravel() == 0)[0], bad)
示例#4
0
def test_generate_binner_mask():
    b = map_to_binner(
        *generate_map_bin(geo, (2048, 2048)),
        np.random.randint(0, 2, 2048 * 2048, dtype=bool).reshape((2048, 2048))
    )
    assert b
示例#5
0
def test_generate_binner():
    a = generate_binner(geo, (2048, 2048))
    b = map_to_binner(*generate_map_bin(geo, (2048, 2048)))
    assert a
    assert b
    assert_equal(a.flatcount, b.flatcount)
示例#6
0
from tifffile import imread
from xpdtools.tools import map_to_binner, generate_map_bin
from profilehooks import profile
import pyFAI
from numba import jit
import numpy as np

geo = pyFAI.load("test.poni")
img = imread("test.tiff")

bo = map_to_binner

binner = bo(*generate_map_bin(geo, img.shape))
f = profile(binner.__call__)
a = binner.xy_argsort


@jit(nopython=True, cache=True)
def b(data):
    return np.max(data)


f(img.flatten(), statistic=np.max)

# median
# standard .255
# numba .2
示例#7
0
def total(geo, img_shape):
    return generate_map_bin(geo, img_shape)