Commit 6b37ba49 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez
Browse files

merge conflict

parent 4c720efc
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@ import logging


import numpy as np
import numpy as np


from scipy.ndimage.measurements import center_of_mass
from skimage import transform as tf
from skimage import transform as tf
from skimage import registration
from skimage import registration
from skimage import filters
from skimage import filters
@@ -1441,10 +1442,10 @@ def mutual_information_match(moving_roi,
               locations within the search area
               locations within the search area
    """
    """
    reference_roi.clip()
    reference_roi.clip()
    moving_roi.clip(affine)
    moving_roi.clip(affine=affine)


    moving_image = moving_roi.clipped_array()
    moving_image = moving_roi.clipped_array
    reference_template = reference_roi.clipped_array()
    reference_template = reference_roi.clipped_array


    if func == None:
    if func == None:
        func = mutual_information
        func = mutual_information
@@ -1485,5 +1486,5 @@ def mutual_information_match(moving_roi,
    x = abs(x - (corr_map.shape[0])/2)
    x = abs(x - (corr_map.shape[0])/2)
    y += subpixel_y_shift
    y += subpixel_y_shift
    x += subpixel_x_shift
    x += subpixel_x_shift
    new_affine = AffineTransform(translation=(-x, -y))
    new_affine = tf.AffineTransform(translation=(-x, -y))
    return new_affine, np.max(max_corr), corr_map
    return new_affine, np.max(max_corr), corr_map
 No newline at end of file
+13 −7
Original line number Original line Diff line number Diff line
@@ -2,9 +2,10 @@ import math
import os
import os
import sys
import sys
import unittest
import unittest
from unittest.mock import patch
from unittest.mock import patch, Mock
import logging
import logging



from skimage import transform as tf
from skimage import transform as tf
from skimage.util import img_as_float   
from skimage.util import img_as_float   
from skimage import color 
from skimage import color 
@@ -15,8 +16,11 @@ import pytest
import numpy as np
import numpy as np
from imageio import imread
from imageio import imread


from plio.io.io_gdal import GeoDataset

from autocnet.examples import get_path
from autocnet.examples import get_path
import autocnet.matcher.subpixel as sp
import autocnet.matcher.subpixel as sp
from autocnet.transformation import roi


@pytest.fixture
@pytest.fixture
def iris_pair(): 
def iris_pair(): 
@@ -270,12 +274,14 @@ def test_subpixel_phase_cooked(x, y, x1, y1, image_size, expected):
def test_mutual_information(): 
def test_mutual_information(): 
    d_template = np.array([[i for i in range(50, 100)] for j in range(50)])
    d_template = np.array([[i for i in range(50, 100)] for j in range(50)])
    s_image = np.ones((100, 100))
    s_image = np.ones((100, 100))

    s_image[25:75, 25:75] = d_template
    s_image[25:75, 25:75] = d_template
    
    
    x_offset, y_offset, max_corr, corr_map = sp.mutual_information_match(d_template, s_image, bins=20)
    template = Mock(spec=roi.Roi, clipped_array = d_template)
    assert x_offset == 0.01711861257171421
    image = Mock(spec=roi.Roi, clipped_array = s_image)
    assert y_offset == 0.0

    affine, max_corr, corr_map = sp.mutual_information_match(image, template, bins=20)
    assert affine.params[0][2] == -0.5171186125717124
    assert affine.params[1][2] == -0.5
    assert max_corr == 2.9755967600033015
    assert max_corr == 2.9755967600033015
    assert corr_map.shape == (51, 51)
    assert corr_map.shape == (51, 51)
    assert np.min(corr_map) >= 0.0
    assert np.min(corr_map) >= 0.0
 No newline at end of file
+9 −1
Original line number Original line Diff line number Diff line
@@ -66,7 +66,13 @@ class Roi():
        self.ndv = ndv
        self.ndv = ndv
        self._ndv_threshold = ndv_threshold
        self._ndv_threshold = ndv_threshold
        self.buffer = buffer
        self.buffer = buffer
        self.clip_center = ()
        self.affine = affine
        self.affine = affine
        self._clipped_array = None

    @property 
    def clipped_array(self):
      return self._clipped_array
    
    
    @property
    @property
    def center(self):
    def center(self):
@@ -174,11 +180,13 @@ class Roi():
        """
        """
        if self.ndv == None:
        if self.ndv == None:
            return True
            return True
        if len(self._clipped_array) == 0:
            return False
        # Check if we have any ndv values this will return an inverted array
        # Check if we have any ndv values this will return an inverted array
        # where all no data values are true, we need to then invert the array
        # where all no data values are true, we need to then invert the array
        # and return the all result. This ensures that a valid array will return
        # and return the all result. This ensures that a valid array will return
        # True
        # True
        return np.invert(np.isclose(self.ndv, self.clipped_array)).all()
        return np.invert(np.isclose(self.ndv, self._clipped_array)).all()




    @property
    @property