Code Monkey home page Code Monkey logo

noise_gating's Introduction

Noise gater

Warning

This code is no longer maintained. I highly suggest using Craig DeForest's Cython version now.

Background

This is a python implementation of DeForest (2017)'s approach to reducing noise in images using regional fourier transforms to remove noise from images. For the full details of how it works, please refer to the original paper in The Astrophysical Journal, Volume 838, Issue 2, article id. 155, 10 pp, 2017.

Setup

Since this was designed for astronomical usage, it only takes FITS as a file format. For other uses, the code can easy be modified to read a different image format in as an array. If you find need for this, please contact me.

To install the dependencies, install via requirements.txt with: pip install -r requirements.txt

Running

The program has two required parameters:

  • __in_directory__: directory containing FITS files to noise gate, order is determined by sorting on the filename
  • __out_directory__: directory to save the noise gated FITS files in

The program has multiple optional parameters with defaults that can be viewed with python run.py --help:

  • __gamma__: this indicates how much noise should be removed, for a more rigorous definition see DeForest (2017)
  • __beta_percentile__: percentile used to determine the beta_approx, eqn 7 in DeForest (2017).
  • __beta_count__: how many image tiles are used when calculating beta_aprox, eqn 7 in DeForest (2017)
  • __width__: size of the image tile cubes used noise gating

Example call:

python run.py IN_DIRECTORY OUT_DIRECTORY

Results

You can see example.mp4 in this folder for the type of improvement expected. A frame from this movie is shown below:

See examples/example.png

The upper left is a good image, no cleaning necessary. However, we often see images like the upper right, dominated by shot noise. This image is created by taking the image on the upper left and adding poisson noise with as ignal-to-noise ratio of 2. The algorithm still performs even if it's worse, although be more careful about artifacts showing up. I use DeForest's algorithm to create the cleaned image on the bottom left. This can be compared to simply smoothing the image to decrease the noise as in the bottom right.

See examples/currentsheet_noisegated.png In the above image, the left is real SUVI 131 angstroms image from at flare on 2017-09-10. At right, is the noisegated result.

For more examples, see the examples folder.

Todo

There are many features not yet added to this code yet:

  • moving computation into C for quicker performance
  • correcting the edges of images and the time series, so they aren't blacked out
  • writing a 2D version
  • comparing results to DeForest's PDL version for correctness

Author

James Marcus Hughes [email protected]

noise_gating's People

Contributors

jmbhughes avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

noise_gating's Issues

Matrix size mismatch: image_section and hanning_window

Hi
Just stumbled on your toolbox looking for DeForest filter, really great job. I'm looking to use this filter on brain imaging data.

I've made it most of the way through your routines (removed arguments for now), except that the hanning filter and the image sections don't seem to be matching in size (see below). I may have a weird image stack shape, but it should otherwise work. I added +1 to the section function that slices from self.image_cube and am running it now, but I didn't think that's what you intended.

Any advice on why these are not matching?


cat@catlab:~/code/noise_gating$ python noise_gater_3d.py
Making image cube
(45, 80, 63500) #My image stack shape
Cleaning image, this may take a while!
10 35 3 #xstart, xend, xstep
10 70 3 #ystart, yend, ystep
10 63490 3 #tstart, tend, tstep
3808800 10000
Traceback (most recent call last):
File "noise_gater_3d.py", line 212, in
clean_cube = ng.clean()
File "noise_gater_3d.py", line 165, in clean
t-self.twidth//2 : t+self.twidth//2] += section
ValueError: operands could not be broadcast together with shapes (4,4,4) (5,5,5) (4,4,4)

EDIT: Ok, I see now that there's an integer divide which rounds off and can make the hanning_window different than the cube being processed. So I have to choose an even step as well as probably a larger FOV.

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.