Loading .travis.yml +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ before_install: # Install dependencies - conda config --add channels conda-forge - conda config --set ssl_verify false - conda install -c conda-forge vlfeat scipy networkx numexpr cython matplotlib pillow runipy geopandas opencv numpy libgdal gdal - conda install -c conda-forge vlfeat scipy networkx numexpr cython matplotlib pillow runipy geopandas opencv numpy libgdal gdal scikit-image - conda install -c menpo cyvlfeat - conda install -c usgs-astrogeology plio Loading autocnet/matcher/subpixel.py +34 −0 Original line number Diff line number Diff line import numpy as np from skimage.feature import register_translation from autocnet.matcher import naive_template from autocnet.matcher import ciratefi Loading Loading @@ -55,6 +57,38 @@ def clip_roi(img, center, img_size): x_stop + 1, y_stop + 1]) return clipped_img def subpixel_phase(template, search, **kwargs): """ Apply the spectral domain matcher to a search and template image. To shift the images, the x_shift and y_shift, need to be subtracted from the center of the search image. It may also be necessary to apply the fractional pixel adjustment as well (if for example the center of the search is not an integer); this function do not manage shifting. Parameters ---------- template : ndarray The template used to search search : ndarray The search image Returns ------- x_offset : float Shift in the x-dimension y_offset : float Shift in the y-dimension strength : tuple With the RMSE error and absolute difference in phase """ if not template.shape == search.shape: raise ValueError('Both the template and search images must be the same shape.') (y_shift, x_shift), error, diffphase = register_translation(search, template, **kwargs) return x_shift, y_shift, (error, diffphase) def subpixel_offset(template, search, **kwargs): """ Loading autocnet/matcher/tests/test_subpixel.py +34 −12 Original line number Diff line number Diff line Loading @@ -2,27 +2,49 @@ import os import sys import unittest import numpy as np from .. import subpixel as sp import pytest sys.path.append(os.path.abspath('..')) import numpy as np from scipy.ndimage import imread from autocnet.examples import get_path import autocnet.matcher.subpixel as sp class TestSubPixel(unittest.TestCase): def setup(self): pass @pytest.fixture def apollo_subsets(): arr1 = imread(get_path('AS15-M-0295_SML(1).png'))[100:200, 123:223] arr2 = imread(get_path('AS15-M-0295_SML(2).png'))[235:335, 95:195] print(arr1.shape, arr2.shape) return arr1, arr2 def test_clip_roi(self): def test_clip_roi(): img = np.arange(10000).reshape(100, 100) center = (4, 4) clip = sp.clip_roi(img, center, 9) self.assertEqual(clip.mean(), 404) assert clip.mean() == 404 center = (55.4, 63.1) clip = sp.clip_roi(img, center, 27) self.assertEqual(clip.mean(), 6355.0) self.assertRaises(ValueError, sp.clip_roi, img, center, 10) assert clip.mean() == 6355.0 def test_subpixel_phase(apollo_subsets): a = apollo_subsets[0] b = apollo_subsets[1] xoff, yoff, err = sp.subpixel_phase(a, b) assert xoff == 0 assert yoff == 2 assert len(err) == 2 def test_subpixel_template(apollo_subsets): a = apollo_subsets[0] b = apollo_subsets[1] midy = int(b.shape[0] / 2) midx = int(b.shape[1] / 2) subb = b[midy-10:midy+10, midx-10:midx+10] xoff, yoff, err = sp.subpixel_offset(subb, a) assert xoff == 0.0625 assert yoff == 2.125 assert err == 0.9905822277069092 conda/meta.yaml +2 −1 Original line number Diff line number Diff line package: name: autocnet version: 0.2.1 version: 0.2.2 channels: - conda-forge Loading Loading @@ -42,6 +42,7 @@ requirements: - numpy - plio - gdal - scikit-image test: imports: Loading setup.py +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ def setup_package(): setup( name = "autocnet", version = '0.2.1', version = '0.2.2', author = "Jay Laura", author_email = "jlaura@usgs.gov", description = ("I/O API to support planetary data formats."), Loading Loading
.travis.yml +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ before_install: # Install dependencies - conda config --add channels conda-forge - conda config --set ssl_verify false - conda install -c conda-forge vlfeat scipy networkx numexpr cython matplotlib pillow runipy geopandas opencv numpy libgdal gdal - conda install -c conda-forge vlfeat scipy networkx numexpr cython matplotlib pillow runipy geopandas opencv numpy libgdal gdal scikit-image - conda install -c menpo cyvlfeat - conda install -c usgs-astrogeology plio Loading
autocnet/matcher/subpixel.py +34 −0 Original line number Diff line number Diff line import numpy as np from skimage.feature import register_translation from autocnet.matcher import naive_template from autocnet.matcher import ciratefi Loading Loading @@ -55,6 +57,38 @@ def clip_roi(img, center, img_size): x_stop + 1, y_stop + 1]) return clipped_img def subpixel_phase(template, search, **kwargs): """ Apply the spectral domain matcher to a search and template image. To shift the images, the x_shift and y_shift, need to be subtracted from the center of the search image. It may also be necessary to apply the fractional pixel adjustment as well (if for example the center of the search is not an integer); this function do not manage shifting. Parameters ---------- template : ndarray The template used to search search : ndarray The search image Returns ------- x_offset : float Shift in the x-dimension y_offset : float Shift in the y-dimension strength : tuple With the RMSE error and absolute difference in phase """ if not template.shape == search.shape: raise ValueError('Both the template and search images must be the same shape.') (y_shift, x_shift), error, diffphase = register_translation(search, template, **kwargs) return x_shift, y_shift, (error, diffphase) def subpixel_offset(template, search, **kwargs): """ Loading
autocnet/matcher/tests/test_subpixel.py +34 −12 Original line number Diff line number Diff line Loading @@ -2,27 +2,49 @@ import os import sys import unittest import numpy as np from .. import subpixel as sp import pytest sys.path.append(os.path.abspath('..')) import numpy as np from scipy.ndimage import imread from autocnet.examples import get_path import autocnet.matcher.subpixel as sp class TestSubPixel(unittest.TestCase): def setup(self): pass @pytest.fixture def apollo_subsets(): arr1 = imread(get_path('AS15-M-0295_SML(1).png'))[100:200, 123:223] arr2 = imread(get_path('AS15-M-0295_SML(2).png'))[235:335, 95:195] print(arr1.shape, arr2.shape) return arr1, arr2 def test_clip_roi(self): def test_clip_roi(): img = np.arange(10000).reshape(100, 100) center = (4, 4) clip = sp.clip_roi(img, center, 9) self.assertEqual(clip.mean(), 404) assert clip.mean() == 404 center = (55.4, 63.1) clip = sp.clip_roi(img, center, 27) self.assertEqual(clip.mean(), 6355.0) self.assertRaises(ValueError, sp.clip_roi, img, center, 10) assert clip.mean() == 6355.0 def test_subpixel_phase(apollo_subsets): a = apollo_subsets[0] b = apollo_subsets[1] xoff, yoff, err = sp.subpixel_phase(a, b) assert xoff == 0 assert yoff == 2 assert len(err) == 2 def test_subpixel_template(apollo_subsets): a = apollo_subsets[0] b = apollo_subsets[1] midy = int(b.shape[0] / 2) midx = int(b.shape[1] / 2) subb = b[midy-10:midy+10, midx-10:midx+10] xoff, yoff, err = sp.subpixel_offset(subb, a) assert xoff == 0.0625 assert yoff == 2.125 assert err == 0.9905822277069092
conda/meta.yaml +2 −1 Original line number Diff line number Diff line package: name: autocnet version: 0.2.1 version: 0.2.2 channels: - conda-forge Loading Loading @@ -42,6 +42,7 @@ requirements: - numpy - plio - gdal - scikit-image test: imports: Loading
setup.py +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ def setup_package(): setup( name = "autocnet", version = '0.2.1', version = '0.2.2', author = "Jay Laura", author_email = "jlaura@usgs.gov", description = ("I/O API to support planetary data formats."), Loading