Commit 05c11fa6 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez
Browse files

merge conflict

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

import numpy as np

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

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

    if func == None:
        func = mutual_information
@@ -1485,5 +1486,5 @@ def mutual_information_match(moving_roi,
    x = abs(x - (corr_map.shape[0])/2)
    y += subpixel_y_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
 No newline at end of file
+13 −7
Original line number Diff line number Diff line
@@ -2,9 +2,10 @@ import math
import os
import sys
import unittest
from unittest.mock import patch
from unittest.mock import patch, Mock
import logging


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

from plio.io.io_gdal import GeoDataset

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

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

    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)
    assert x_offset == 0.01711861257171421
    assert y_offset == 0.0
    template = Mock(spec=roi.Roi, clipped_array = d_template)
    image = Mock(spec=roi.Roi, clipped_array = s_image)

    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 corr_map.shape == (51, 51)
    assert np.min(corr_map) >= 0.0
 No newline at end of file
+9 −1
Original line number Diff line number Diff line
@@ -66,7 +66,13 @@ class Roi():
        self.ndv = ndv
        self._ndv_threshold = ndv_threshold
        self.buffer = buffer
        self.clip_center = ()
        self.affine = affine
        self._clipped_array = None

    @property 
    def clipped_array(self):
      return self._clipped_array
    
    @property
    def center(self):
@@ -174,11 +180,13 @@ class Roi():
        """
        if self.ndv == None:
            return True
        if len(self._clipped_array) == 0:
            return False
        # 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
        # and return the all result. This ensures that a valid array will return
        # True
        return np.invert(np.isclose(self.ndv, self.clipped_array)).all()
        return np.invert(np.isclose(self.ndv, self._clipped_array)).all()


    @property