I. INTRODUCTION

Motion deblur reduces the blurring caused by objects in quick motion during the
image acquisition process. The algorythm employed is based on Weiner 
deconvolution.

II. HOW TO USE

1. 	Load any kind of image supported by ImageJ.

2. 	Load "Motion Deblur" plugin: note that it will hook to the active image.

3. 	Specify parameters to determine the point spread function and the
	signal-to-noise ratio to compensate. This can be done in three ways:
   
	a.	Using the line tool: drag a line on the hooked image canvas
	   	(Shift/Angle only).
	
	b. 	Using the sliders.
	
	c. 	Manually entering textual information in textboxes. Max shift 
		allowedis half of the shortest image dimension, while max angle is 
	   	180 degrees.
	   	
4.	"Apply filter" will process the image and create a new window. (Optional:
    by ticking the "Show OTF" checkbox the plugin will create another window 
    showing the OTF power spectrum).

5.	(Optional) "Generate report" will create a forensics report that will
	include the following information:
	
	*	User, machine and current timestamp.
	
	*	Original and processed image filenames and MD5 hashes. Note that 
	    processed image will be saved as a Bitmap file to prevent further
	    degradation.
	    
	*	Shift, Angle and SNR.
	
	* 	Bibliographic references.
	
III. HOW DOES IT WORK

The algorithm is divided in three steps:

1.	Generate the point spread function given the specified angle and shift.

	The point spread function matrix h is generated as it follows:

	a.	Construct an ideal line segment with the desired length and angle, 
		centered at the center coefficient of h.

	b.	For each coefficient location (x,y), compute the nearest distance  
		between that location and the ideal line segment.

	c.	h(x,y) = max(1 - nearest_distance(x,y), 0). The distance shows how much
		h(x,y) belongs to the ideal line segment. If it is 1, h(x,y) lies on 
		the ideal line segment, if it is <= 0 it doesn't belong to the ideal 
		line segment.

	d.	Normalize h so that the sum of all coefficients is exactly 1.

2.	Obtain the degradation function H from the computed PSF.

	Obtaining the OTF from the calculated PSF is a matter of zero-padding the 
	PSF matrix so that it has the same size of the degraded image, add a
	circular shift so that the center of the padded PSF lies on position 
	(0, 0), and computing its FFT.

3.	Apply the weiner filter given H and the SNR ratio to compensate.

	The simplified weiner filter is defined as follows:
	
			     H*(u,v)
	W(u,v) = ----------------
			 |H(u,v)^2| + SNR
			  
	Note that the denominator is always non-zero, thus having no problems
	with divides by zero. The reconstructed image is obtained as it follows:
	
	f(x,y) = ifft(W(u,v) * G(u,v))
	
	Where G is the blurred image's FFT. All operations are point-to-point, not
	matricial (the element at (i,j) is the result of the scalar operation 
	having as operands the elements at position (i,j)).
	
IV. LICENSING

"Motion Deblur" is distributed under the terms of the Simplified BSD license. 
To compute the FFT, it utilizes part of the JTransforms library by Piotr
Wendykier, released under the terms of the LGPL/GPL/MPL tri-license, check
his google code page for further information:

https://sites.google.com/site/piotrwendykier/software/jtransforms
