GithubHelp home page GithubHelp logo

simon-bertrand / 2dphasecongruency-pytorch Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 713 KB

The 2D phase congruency algorithm using monogenic filters implemented in PyTorch and originally written by Peter Kovesi on Matlab.

License: GNU General Public License v3.0

Python 97.91% Shell 2.09%

2dphasecongruency-pytorch's Introduction

Python library : torch_phasecong

The torch_phasecong library provides the 2D phase congruency algorithm using monogenic filters implemented in PyTorch and originally written by Peter Kovesi on Matlab.


References :


Install library

%%bash
if !python -c "import torch_phasecong" 2>/dev/null; then
    pip install https://github.com/Simon-Bertrand/2DPhaseCongruency-PyTorch/archive/main.zip
fi

Import library

import torch_phasecong

Load data

!pip install -q torchvision requests matplotlib
import tempfile
import torchvision
import torch.nn.functional as F
import requests
import torch
with tempfile.NamedTemporaryFile() as fp:
    fp.write(requests.get("https://upload.wikimedia.org/wikipedia/commons/a/ab/Mandrill-k-means.png").content)
    im = F.interpolate((torchvision.io.read_image(fp.name, torchvision.io.ImageReadMode.RGB).unsqueeze(0)
    .to(torch.float64)
    .div(255)), size=(256, 256), mode='bicubic', align_corners=False)
�[1m[�[0m�[34;49mnotice�[0m�[1;39;49m]�[0m�[39;49m A new release of pip is available: �[0m�[31;49m23.2.1�[0m�[39;49m -> �[0m�[32;49m24.0�[0m
�[1m[�[0m�[34;49mnotice�[0m�[1;39;49m]�[0m�[39;49m To update, run: �[0m�[32;49mpip install --upgrade pip�[0m

Compute phase congruency

phaseCong = torch_phasecong.phasecong(im[0,0])
import matplotlib.pyplot as plt
plt.imshow(phaseCong[2], cmap="gray")
plt.imshow(im[0].moveaxis(0,-1), alpha=0.3)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).





<matplotlib.image.AxesImage at 0x7f4175026410>

png

2dphasecongruency-pytorch's People

Contributors

simon-bertrand avatar

Stargazers

 avatar Edward avatar  avatar

Watchers

 avatar

Forkers

zfd1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.