当前位置: 首页>>代码示例>>Python>>正文


Python spectral.open_image函数代码示例

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


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

示例1: test_save_load_classes

 def test_save_load_classes(self):
     '''Verify that `envi.save_classification` saves data correctly.'''
     import spectral as spy
     fname = os.path.join(testdir, 'test_save_load_classes.hdr')
     gt = spy.open_image('92AV3GT.GIS').read_band(0)
     spy.envi.save_classification(fname, gt, dtype=np.uint8)
     gt2 = spy.open_image(fname).read_band(0)
     assert(np.all(gt == gt2))
开发者ID:cheneason,项目名称:spectral,代码行数:8,代码来源:envi.py

示例2: setup

 def setup(self):
     if not os.path.isdir(testdir):
         os.mkdir(testdir)
     self.image = spy.open_image('92AV3C.lan')
     self.data = self.image.load()
     self.gt = spy.open_image('92AV3GT.GIS').read_band(0)
     self.ts = spy.create_training_classes(self.data, self.gt,
                                           calc_stats=True)
     self.class_filename = os.path.join(testdir, '92AV3C.classes')
开发者ID:Pdgraham,项目名称:spectral,代码行数:9,代码来源:classifiers.py

示例3: test_save_image_spyfile

 def test_save_image_spyfile(self):
     '''Test saving an ENVI formatted image from a SpyFile object.'''
     import os
     import spectral
     (r, b, c) = (3, 8, 23)
     fname = os.path.join(testdir, 'test_save_image_spyfile.hdr')
     src = spectral.open_image('92AV3C.lan')
     spectral.envi.save_image(fname, src)
     img = spectral.open_image(fname)
     assert_almost_equal(src[r, b, c], img[r, b, c])
开发者ID:cheneason,项目名称:spectral,代码行数:10,代码来源:envi.py

示例4: create_test_image_file

 def create_test_image_file(self):
     import os
     import spectral
     img = spectral.open_image(self.file)
     fname = os.path.join(testdir, 'memmap_test_%s.hdr' % self.src_inter)
     spectral.envi.save_image(fname,
                              img,
                              dtype = img.dtype,
                              interleave = self.src_inter,
                              force=True)
     self.image = spectral.open_image(fname)
开发者ID:Pdgraham,项目名称:spectral,代码行数:11,代码来源:memmap.py

示例5: test_create_image_metadata

 def test_create_image_metadata(self):
     '''Test calling `envi.create_image` using a metadata dict.'''
     import os
     import spectral
     (R, B, C) = (10, 20, 30)
     (r, b, c) = (3, 8, 23)
     offset = 1024
     datum = 33
     md = {'lines': R,
           'samples': B,
           'bands': C,
           'interleave': 'bsq',
           'header offset': offset,
           'data type': 12,
           'USER DEFINED': 'test case insensitivity'}
     fname = os.path.join(testdir, 'test_create_image_metadata.hdr')
     img = spectral.envi.create_image(fname, md)
     mm = img.open_memmap(writable=True)
     mm.fill(0)
     mm[r, b, c] = datum
     mm.flush()
     img = spectral.open_image(fname)
     img._disable_memmap()
     assert_almost_equal(img[r, b, c], datum)
     assert(img.offset == offset)
     for key in md:
         assert key.lower() in img.metadata
         assert str(md[key]) == img.metadata[key.lower()]
开发者ID:avstjohn,项目名称:spectral,代码行数:28,代码来源:envi.py

示例6: setup

 def setup(self):
     import spectral
     from spectral.io.spyfile import SpyFile
     if isinstance(self.file, SpyFile):
         self.image = self.file
     else:
         self.image = spectral.open_image(self.file)
开发者ID:avstjohn,项目名称:spectral,代码行数:7,代码来源:spyfile.py

示例7: test_save_zero_frame_offset_passes

 def test_save_zero_frame_offset_passes(self):
     '''Opening files with nonzero frame offsets should fail.'''
     import os
     import spectral as spy
     img = spy.open_image('92AV3C.lan')
     fname = os.path.join(testdir, 'test_save_zero_frame_offset_passes.hdr')
     meta = {'major frame offsets' : 0}
     spy.envi.save_image(fname, img, metadata=meta)
开发者ID:avstjohn,项目名称:spectral,代码行数:8,代码来源:envi.py

示例8: setup

    def setup(self):
        from spectral.algorithms.detectors import MatchedFilter
        self.data = spy.open_image('92AV3C.lan').load()
        self.background = spy.calc_stats(self.data)
        self.target_ij = [33, 87]
#        self.target = self.data[33, 87]
        (i, j) = self.target_ij
        self.mf = MatchedFilter(self.background, self.data[i, j])
开发者ID:Pdgraham,项目名称:spectral,代码行数:8,代码来源:detectors.py

示例9: run

    def run(self):
        import os
        import itertools
        import spectral
        from spectral.tests import testdir

        print('\n' + '-' * 72)
        print('Running SpyFile read tests.')
        print('-' * 72)

        if not os.path.isdir(testdir):
            os.mkdir(testdir)
        image = spectral.open_image(self.filename)
        basename = os.path.join(testdir,
                                os.path.splitext(self.filename)[0])
        interleaves = ('bil', 'bip', 'bsq')
        ends = ('big', 'little')
        cases = itertools.product(interleaves, self.dtypes, ends)
        for (inter, dtype, endian) in cases:
            fname = '%s_%s_%s_%s.hdr' % (basename, inter, dtype,
                                         endian)
            spectral.envi.save_image(fname, image, interleave=inter,
                                     dtype=dtype, byteorder=endian)
            msg = 'Running SpyFile read tests on %s %s %s-endian file ' \
                % (inter.upper(), np.dtype(dtype).name, endian)
            testimg = spectral.open_image(fname)
            if testimg.using_memmap is True:
                print('\n' + '-' * 72)
                print(msg + 'using memmap...')
                print('-' * 72)
                test = SpyFileTest(testimg, self.datum, self.value)
                test.run()
                print('\n' + '-' * 72)
                print(msg + 'without memmap...')
                print('-' * 72)
                testimg._disable_memmap()
                test = SpyFileTest(testimg, self.datum, self.value)
                test.run()
            else:
                print('\n' + '-' * 72)
                print(msg + 'without memmap...')
                print('-' * 72)
                test = SpyFileTest(testimg, self.datum, self.value)
                test.run()
开发者ID:avstjohn,项目名称:spectral,代码行数:44,代码来源:spyfile.py

示例10: test_save_image_ndarray_no_ext

 def test_save_image_ndarray_no_ext(self):
     '''Test saving an ENVI formated image with no image file extension.'''
     import os
     import spectral
     data = np.arange(1000, dtype=np.int16).reshape(10, 10, 10)
     base = os.path.join(testdir, 'test_save_image_ndarray_noext')
     hdr_file = base + '.hdr'
     spectral.envi.save_image(hdr_file, data, ext='')
     rdata = spectral.open_image(hdr_file).load()
     assert(np.all(data==rdata))
开发者ID:cheneason,项目名称:spectral,代码行数:10,代码来源:envi.py

示例11: test_iterator_spyfile_nomemmap

 def test_iterator_spyfile_nomemmap(self):
     '''Iteration over SpyFile object without memmap'''
     from spectral.algorithms.algorithms import iterator
     i = 5
     data = self.image.load()
     classes = self.gt.ravel()
     pixels = data.reshape((-1, data.shape[-1]))
     sum = np.sum(pixels[classes == 5], 0)
     image = spy.open_image('92AV3C.lan')
     itsum = np.sum(np.array([x for x in iterator(image, classes, 5)]), 0)
     assert_allclose(sum, itsum)
开发者ID:appscluster,项目名称:spectral,代码行数:11,代码来源:iterators.py

示例12: test_open_zero_frame_offset_passes

 def test_open_zero_frame_offset_passes(self):
     '''Files with frame offsets set to zero should open.'''
     import os
     import spectral as spy
     img = spy.open_image('92AV3C.lan')
     fname = os.path.join(testdir, 'test_open_zero_frame_offset_passes.hdr')
     spy.envi.save_image(fname, img)
     fout = open(fname, 'a')
     fout.write('major frame offsets = 0\n')
     fout.write('minor frame offsets = {0, 0}\n')
     fout.close()
     img2 = spy.envi.open(fname)
开发者ID:avstjohn,项目名称:spectral,代码行数:12,代码来源:envi.py

示例13: test_save_image_ndarray

 def test_save_image_ndarray(self):
     '''Test saving an ENVI formated image from a numpy.ndarray.'''
     import os
     import spectral
     (R, B, C) = (10, 20, 30)
     (r, b, c) = (3, 8, 23)
     datum = 33
     data = np.zeros((R, B, C), dtype=np.uint16)
     data[r, b, c] = datum
     fname = os.path.join(testdir, 'test_save_image_ndarray.hdr')
     spectral.envi.save_image(fname, data, interleave='bil')
     img = spectral.open_image(fname)
     assert_almost_equal(img[r, b, c], datum)
开发者ID:cheneason,项目名称:spectral,代码行数:13,代码来源:envi.py

示例14: test_save_nonzero_frame_offset_fails

 def test_save_nonzero_frame_offset_fails(self):
     '''Opening files with nonzero frame offsets should fail.'''
     import os
     import spectral as spy
     img = spy.open_image('92AV3C.lan')
     fname = os.path.join(testdir, 'test_save_nonzero_frame_offset_fails.hdr')
     meta = {'major frame offsets' : [128, 0]}
     try:
         spy.envi.save_image(fname, img, metadata=meta)
     except spy.envi.EnviFeatureNotSupported:
         pass
     else:
         raise Exception('File erroneously saved.')
开发者ID:avstjohn,项目名称:spectral,代码行数:13,代码来源:envi.py

示例15: test_open_nonzero_frame_offset_fails

 def test_open_nonzero_frame_offset_fails(self):
     '''Opening files with nonzero frame offsets should fail.'''
     import os
     import spectral as spy
     img = spy.open_image('92AV3C.lan')
     fname = os.path.join(testdir, 'test_open_nonzero_frame_offset_fails.hdr')
     spy.envi.save_image(fname, img)
     fout = open(fname, 'a')
     fout.write('major frame offsets = 128\n')
     fout.close()
     try:
         img2 = spy.envi.open(fname)
     except spy.envi.EnviFeatureNotSupported:
         pass
     else:
         raise Exception('File erroneously opened.')
开发者ID:avstjohn,项目名称:spectral,代码行数:16,代码来源:envi.py


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