Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added mask of ones, if no mask is given #41

Merged
merged 3 commits into from
Aug 16, 2022

Conversation

kremeyer
Copy link
Contributor

if mask is None, you will get an IndexError from scikit-image. This is because arr1 and arr2 will have different shapes than m1 and m2.

def cross_correlate_masked(arr1, arr2, m1, m2, mode='full', axes=(-2, -1),
                           overlap_ratio=0.3):
    """
    Masked normalized cross-correlation between arrays.

    Parameters
    ----------
    arr1 : ndarray
        First array.
    arr2 : ndarray
        Seconds array. The dimensions of `arr2` along axes that are not
        transformed should be equal to that of `arr1`.
    m1 : ndarray
        Mask of `arr1`. The mask should evaluate to `True`
        (or 1) on valid pixels. `m1` should have the same shape as `arr1`.
    m2 : ndarray
        Mask of `arr2`. The mask should evaluate to `True`
        (or 1) on valid pixels. `m2` should have the same shape as `arr2`.
    mode : {'full', 'same'}, optional
        'full':
            This returns the convolution at each point of overlap. At
            the end-points of the convolution, the signals do not overlap
            completely, and boundary effects may be seen.
        'same':
            The output is the same size as `arr1`, centered with respect
            to the `‘full’` output. Boundary effects are less prominent.
    axes : tuple of ints, optional
        Axes along which to compute the cross-correlation.
    overlap_ratio : float, optional
        Minimum allowed overlap ratio between images. The correlation for
        translations corresponding with an overlap ratio lower than this
        threshold will be ignored. A lower `overlap_ratio` leads to smaller
        maximum translation, while a higher `overlap_ratio` leads to greater
        robustness against spurious matches due to small overlap between
        masked images.

    Returns
    -------
    out : ndarray
        Masked normalized cross-correlation.

    Raises
    ------
    ValueError : if correlation `mode` is not valid, or array dimensions along
        non-transformation axes are not equal.

    References
    ----------
    .. [1] Dirk Padfield. Masked Object Registration in the Fourier Domain.
           IEEE Transactions on Image Processing, vol. 21(5),
           pp. 2706-2718 (2012). :DOI:`10.1109/TIP.2011.2181402`
    .. [2] D. Padfield. "Masked FFT registration". In Proc. Computer Vision and
           Pattern Recognition, pp. 2918-2925 (2010).
           :DOI:`10.1109/CVPR.2010.5540032`
    """

source

if mask is None, you will get an IndexError from
/skimage/registration/_masked_phase_cross_correlation.py", line 301, in _flip
reverse[axis] = slice(None, None, -1)
IndexError: list assignment index out of range
@LaurentRDC
Copy link
Owner

@kremeyer Can you add a test case where the test fails without your patch? Thanks

@LaurentRDC
Copy link
Owner

Also, the lint test won't work until you run the formatter black over the code base

@kremeyer
Copy link
Contributor Author

Totally unrelated thing I stumbled upon:
In the README.md you put python -m pip install git+git://github.com/LaurentRDC/scikit-ued.git as installation instructions. The git protocol fails for on my machine. Is there a good reason to use git instead of https or ssh?

@LaurentRDC
Copy link
Owner

Totally unrelated thing I stumbled upon: In the README.md you put python -m pip install git+git://github.com/LaurentRDC/scikit-ued.git as installation instructions. The git protocol fails for on my machine. Is there a good reason to use git instead of https or ssh?

Hmm I haven't use this for a while. Maybe it does not work anymore. I'll update it.

@LaurentRDC LaurentRDC merged commit 884d1ca into LaurentRDC:master Aug 16, 2022
@LaurentRDC
Copy link
Owner

Release 2.1.10 is underway with this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants