Git Product home page Git Product logo

phase-retrieval's Introduction

phase-retrieval

A small library implementing phase retrieval algorithms for 2D images.

The code in the repository was created for a project in AM216 at Harvard University.

PhaseRetrieval

The main piece of this repository is the PhaseRetrieval object. Once initialized with a set of Fourier Magnitudes. It can carry out several Fienup algorithms (Error reduction, HIO, CHIO) as well as prRED. The object also contains a few methods to asses the success or failure of a given phase retrieval algorithm including tracking of the Fourier space error, real space error, and successive real space guesses.

Dependencies

The notebooks in Notebooks are a hodgepodge of python 2.7 and 3.6. The few in the main directory use python 3.6.

numpy
scipy
matplotlib
skimage
keras (if using prDeep)
tensorflow 
fasta-python #https://github.com/phasepack/fasta-python 

Basic Usage

im = np.load("some_file.npy") #Load an image
mags = np.abs(np.fft.fftn(im)) #Compute FFT and take only the magnitudes

pr = PhaseRetrieval(mags)
pr.CHIO(n_iter=500) #Run Fienup's CHIO algorithm for 500 iterations with default settings

plt.imshow(pr.real_space_guess)
plt.show() #View final result of CHIO

plt.plot(pr.err_track)
plt.show() #See progression of Fourier space error 

DnCNN

Our implementation of DnCNN is based on this repository. You can load our fully trained DnCNN into keras with

from keras.models import load_model

denoiser = load_model("dncnn_50k.h5")

You may find it convenient to define a helper function to handle image reshaping:

def denoise(x):
    shape = x.shape
    tensor_x = x.reshape(shape+(1,))
    return denoiser.predict(tensor_x).reshape(shape)

phase_mixing_utils

This file implements a few handy methods for experimenting with phase mixing, i.e. using the magnitudes from one image and the phases from another. The most interesting method here might be phase_intensity_plot which generates images with pixel brightness determined by the Fourier Magnitued and color determined by the complex phase. An example of this is show at the top of this readme. Other functions mostly thinly wrap numpy and should be self explanatory.

TO DO

  • Post clear example notebooks
  • Post code for creating and training DnCNN (and relevant datasets)
  • Make replicate_cat_duck.ipynb actually replicate Cowtan figures

phase-retrieval's People

Contributors

dhekstra avatar ianhi avatar jbgreisman avatar jrussell25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.