• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python artificial.draw_spots函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trackpy.artificial.draw_spots函数的典型用法代码示例。如果您正苦于以下问题:Python draw_spots函数的具体用法?Python draw_spots怎么用?Python draw_spots使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了draw_spots函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_nocharacterize

    def test_nocharacterize(self):
        pos = gen_nonoverlapping_locations((200, 300), 9, 5)
        image = draw_spots((200, 300), pos, 5)
        f_c = tp.locate(image, 5, engine=self.engine, characterize=True)
        f_nc = tp.locate(image, 5, engine=self.engine, characterize=False)

        assert len(f_nc.columns) == 3
        assert_allclose(f_c.values[:, :3], f_nc.values)
开发者ID:danielballan,项目名称:trackpy,代码行数:8,代码来源:test_feature.py


示例2: test_oldmass_16bit

    def test_oldmass_16bit(self):
        old_minmass = 2800000
        im = draw_spots(self.shape, self.pos, self.size, bitdepth=16,
                        noise_level=10000)

        new_minmass = self.minmass_v02_to_v04(im, old_minmass)
        f = tp.locate(im, self.tp_diameter, minmass=new_minmass)
        assert len(f) == self.N
开发者ID:caspervdw,项目名称:trackpy,代码行数:8,代码来源:test_feature.py


示例3: test_oldmass_16bit

    def test_oldmass_16bit(self):
        old_minmass = 2800000
        im = draw_spots(self.shape, self.pos, self.draw_diameter, bitdepth=16,
                        noise_level=10000)

        new_minmass = tp.minmass_version_change(im, old_minmass,
                                                smoothing_size=self.tp_diameter)
        f = tp.locate(im, self.tp_diameter, minmass=new_minmass)
        assert len(f) == self.N
开发者ID:hadim,项目名称:trackpy,代码行数:9,代码来源:test_feature.py


示例4: test_oldmass_float

    def test_oldmass_float(self):
        old_minmass = 5500
        im = draw_spots(self.shape, self.pos, self.size, bitdepth=8,
                        noise_level=50)
        im = (im / im.max()).astype(np.float)

        new_minmass = self.minmass_v02_to_v04(im, old_minmass)
        f = tp.locate(im, self.tp_diameter, minmass=new_minmass)
        assert len(f) == self.N
开发者ID:caspervdw,项目名称:trackpy,代码行数:9,代码来源:test_feature.py


示例5: test_oldmass_float

    def test_oldmass_float(self):
        old_minmass = 5500
        im = draw_spots(self.shape, self.pos, self.draw_diameter, bitdepth=8,
                        noise_level=50)
        im = (im / im.max()).astype(np.float)

        new_minmass = tp.minmass_version_change(im, old_minmass,
                                                smoothing_size=self.tp_diameter)
        f = tp.locate(im, self.tp_diameter, minmass=new_minmass)
        assert len(f) == self.N
开发者ID:hadim,项目名称:trackpy,代码行数:10,代码来源:test_feature.py


示例6: test_oldmass_invert

    def test_oldmass_invert(self):
        old_minmass = 2800000
        im = draw_spots(self.shape, self.pos, self.draw_diameter, bitdepth=12,
                        noise_level=500)
        im = (im.max() - im + 10000)

        new_minmass = tp.minmass_version_change(im, old_minmass, invert=True,
                                                smoothing_size=self.tp_diameter)
        f = tp.locate(im, self.tp_diameter, minmass=new_minmass, invert=True)
        assert len(f) == self.N
开发者ID:hadim,项目名称:trackpy,代码行数:10,代码来源:test_feature.py


示例7: test_oldmass_invert

    def test_oldmass_invert(self):
        old_minmass = 2800000
        im = draw_spots(self.shape, self.pos, self.size, bitdepth=12,
                        noise_level=500)
        im = (im.max() - im + 10000)

        new_minmass = self.minmass_v02_to_v04(im, old_minmass, invert=True)

        f = tp.locate(invert_image(im), self.tp_diameter, minmass=new_minmass)
        assert len(f) == self.N
开发者ID:caspervdw,项目名称:trackpy,代码行数:10,代码来源:test_feature.py


示例8: test_mass

    def test_mass(self):
        # The mass calculated from the processed image should be independent
        # of added noise. Its absolute value is untested.

        # The mass calculated from the raw image should equal
        # noiseless mass + noise_size/2 * Npx_in_mask.
        self.check_skip()
        ndim = 2
        size = 3    # for drawing
        radius = 6  # for locate
        diameter = radius * 2 + 1
        N = 20
        shape = (128, 127)

        # Calculate the expected mass from a single spot using the set masksize
        center = (diameter,) * ndim
        spot = draw_spots((diameter*2,) * ndim, [center], size, bitdepth=12)
        rect = [slice(c - radius, c + radius + 1) for c in center]
        mask = tp.masks.binary_mask(radius, 2)
        Npx = mask.sum()
        EXPECTED_MASS = (spot[rect] * mask).sum()

        # Generate feature locations and make the image
        expected = gen_nonoverlapping_locations(shape, N, diameter, diameter)
        expected = expected + np.random.random(expected.shape)
        N = expected.shape[0]
        image = draw_spots(shape, expected, size, bitdepth=12)

        # analyze the image without noise
        f = tp.locate(image, diameter, engine=self.engine, topn=N)
        PROCESSED_MASS = f['mass'].mean()
        assert_allclose(f['raw_mass'].mean(), EXPECTED_MASS, rtol=0.01)

        for n, noise in enumerate(np.arange(0.05, 0.8, 0.05)):
            noise_level = int((2**12 - 1) * noise)
            image_noisy = image + np.array(np.random.randint(0, noise_level,
                                                             image.shape),
                                           dtype=image.dtype)
            f = tp.locate(image_noisy, radius*2+1, engine=self.engine, topn=N)
            assert_allclose(f['mass'].mean(), PROCESSED_MASS, rtol=0.1)
            assert_allclose(f['raw_mass'].mean(),
                            EXPECTED_MASS + Npx*noise_level/2, rtol=0.1)
开发者ID:caspervdw,项目名称:trackpy,代码行数:42,代码来源:test_feature.py


示例9: compare

def compare(shape, count, radius, noise_level, engine):
    radius = tp.utils.validate_tuple(radius, len(shape))
    # tp.locate ignores a margin of size radius, take 1 px more to be safe
    margin = tuple([r + 1 for r in radius])
    diameter = tuple([(r * 2) + 1 for r in radius])
    draw_range = tuple([d * 3 for d in diameter])
    cols = ['x', 'y', 'z'][:len(shape)][::-1]
    pos = gen_nonoverlapping_locations(shape, count, draw_range, margin)
    image = draw_spots(shape, pos, draw_range, noise_level)
    f = tp.locate(image, diameter, engine=engine)
    actual = f[cols].sort(cols)
    expected = DataFrame(pos, columns=cols).sort(cols)
    return actual, expected
开发者ID:hadim,项目名称:trackpy,代码行数:13,代码来源:test_feature.py


示例10: compare

def compare(shape, count, radius, noise_level, **kwargs):
    radius = tp.utils.validate_tuple(radius, len(shape))
    # tp.locate ignores a margin of size radius, take 1 px more to be safe
    margin = tuple([r + 1 for r in radius])
    diameter = tuple([(r * 2) + 1 for r in radius])
    size = [d / 2 for d in diameter]
    separation = tuple([d * 3 for d in diameter])
    cols = ['x', 'y', 'z'][:len(shape)][::-1]
    pos = gen_nonoverlapping_locations(shape, count, separation, margin)
    image = draw_spots(shape, pos, size, noise_level)
    f = tp.locate(image, diameter, **kwargs)
    actual = pandas_sort(f[cols], cols)
    expected = pandas_sort(DataFrame(pos, columns=cols), cols)
    return actual, expected
开发者ID:caspervdw,项目名称:trackpy,代码行数:14,代码来源:test_feature.py


示例11: test_ep

    def test_ep(self):
        # Test wether the estimated static error equals the rms deviation from
        # the expected values. Next to the feature mass, the static error is
        # calculated from the estimated image background level and variance.
        # This estimate is also tested here.

        # A threshold is necessary to identify the background array so that
        # background average and standard deviation can be estimated within 1%
        # accuracy.

        # The (absolute) tolerance for ep in this test is 0.05 pixels.
        # Parameters are tweaked so that there is no deviation due to a too
        # small mask size. Signal/noise ratios upto 50% are tested.
        self.check_skip()
        draw_diameter = 21
        locate_diameter = 15
        N = 200
        shape = (512, 513)
        noise_expectation = np.array([1/2., np.sqrt(1/12.)])  # average, stdev

        # Generate feature locations and make the image
        expected = gen_nonoverlapping_locations(shape, N, draw_diameter,
                                                locate_diameter)
        expected = expected + np.random.random(expected.shape)
        N = expected.shape[0]
        image = draw_spots(shape, expected, draw_diameter, bitdepth=12)

        for n, noise in enumerate([0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.5]):
            noise_level = int((2**12 - 1) * noise)
            image_noisy = image + np.array(np.random.randint(0, noise_level,
                                                             image.shape),
                                           dtype=image.dtype)

            f = tp.locate(image_noisy, locate_diameter, engine=self.engine,
                          topn=N, threshold=noise_level/4)

            _, actual = sort_positions(f[['y', 'x']].values, expected)
            rms_dev = np.sqrt(np.mean(np.sum((actual-expected)**2, 1)))
            assert_allclose(rms_dev, f['ep'].mean(), atol=0.05)

            # Additionally test the measured noise
            actual_noise = tp.uncertainty.measure_noise(image_noisy,
                                                        locate_diameter,
                                                        noise_level/4)
            assert_allclose(actual_noise, noise_expectation * noise_level,
                            rtol=0.01, atol=1)
开发者ID:fayazr,项目名称:trackpy,代码行数:46,代码来源:test_feature.py


示例12: import

from __future__ import division
import nose
from numpy.testing.utils import assert_allclose
from trackpy.preprocessing import (bandpass, legacy_bandpass,
                                   legacy_bandpass_fftw)
from trackpy.artificial import gen_nonoverlapping_locations, draw_spots
from trackpy.tests.common import StrictTestCase


pos = gen_nonoverlapping_locations((512, 512), 200, 20)
frame = draw_spots((512, 512), pos, 20, noise_level=100)
margin = 11
bp_scipy = bandpass(frame, 3, 11)[margin:-margin, margin:-margin]


def test_legacy_bandpass():
    lbp_numpy = legacy_bandpass(frame, 3, 11)[margin:-margin, margin:-margin]
    assert_allclose(lbp_numpy, bp_scipy, atol=1.1)


def test_legacy_bandpass_fftw():
    try:
        import pyfftw
    except ImportError:
        raise nose.SkipTest("pyfftw not installed. Skipping.")
    lbp_fftw = legacy_bandpass_fftw(frame, 3, 11)[margin:-margin, margin:-margin]
    assert_allclose(lbp_fftw, bp_scipy, atol=1.1)

if __name__ == '__main__':
    import nose
    nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:31,代码来源:test_preprocessing.py


示例13: setUp

 def setUp(self):
     pos = gen_nonoverlapping_locations((512, 512), 200, 20)
     self.frame = draw_spots((512, 512), pos, 20, noise_level=100)
     self.margin = 11
     self.bp_scipy = bandpass(self.frame, 2, 11)[self.margin:-self.margin,
                                                 self.margin:-self.margin]
开发者ID:caspervdw,项目名称:trackpy,代码行数:6,代码来源:test_preprocessing.py



注:本文中的trackpy.artificial.draw_spots函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.assert_traj_equal函数代码示例发布时间:2022-05-27
下一篇:
Python artificial.draw_feature函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap