Downloading and running UnBlur for simple images
This page describes how to download and run the UnBlur program for simple images. It is presented here in a question and answer format. It is assumed that you have some technical and computer experience.
I have a Windows PC and just want to try out UnBlur quickly. What do I need?
The UnBlur program runs from the command line. If you don’t know what this means, or are not comfortable working from a command prompt, you cannot use the program.
If you are comfortable using a command prompt, then right-click quick_ub.zip, save it into a folder of your choice, and unzip the files contained within it. If you are not able to unzip files, then right-click and save each of the following files into your folder of choice:
You now need a (sharp) test image to start with, in BMP format. It must either be 8-bit greyscale, or 24-bit colour, and it must not be in compressed format. Don’t choose an image that is too large: deblurring is a time-intensive operation. Start off with something that is less than 100 x 100 pixels in size.
You now need to create an 8-bit greyscale image that is to be your point spread function image. If you don’t know what this is, read the section below. As a first trial, use a point spread function that is a straight line in some direction, no more than about 10 pixels in length.
Put both of these files in the same folder as the files above. Now open your command prompt, change to that folder, and type
blur inputfile psffile outputfile
where you omit the “.bmp” from all the filenames. If everything has gone well, then after some processing you should have an output file that is the result of blurring your input file with the point spread function.
You can now use the UnBlur program to try to deblur this blurred image, knowing only the point spread function (not the original sharp image). Type
deblur inputfile psffile outputfile
where now your input file will be the output file from the first step. After some processing, the program’s best estimate of the original (unblurred) image will be written to the output filename.
Those simple examples work just fine for me. Can I just use the program like that?
Sure. You can put the files above in a convenient folder, and set the unblur environment string in your autoexec.bat (or command prompt properties) to that folder; for example,
set unblur=c:\Program Files\UnBlur\
(Note that the final backslash is crucial!) You will then need to either include this directory in your path setting, or else copy the files blur.bat and deblur.bat into a folder that is in your path.
What is a point spread function? How do I create one?
The point spread function (“psf”) is an image of what each single point (pixel) has been blurred into. You must determine (or guess) for yourself, based on your blurred image, what the point spread function is. For motion-blur, it will often be a straight line.
To create a point spread function file, create a greyscale BMP image, just large enough to contain the point spread function. The background must be white; the point spread function will be represented by darkness. For example, no blur at all would be represented by a single black (or grey) pixel on a white background. The overall darkness of the image is of no importance; what matters is the relative darkness of the pixels. Thus, for a motion blur, you will often just draw a straight black line of width one pixel, with the desired length and direction, using a paint program like Adobe Photoshop.
Any white pixel (RGB values of 255, 255, 255) will be taken to have zero contribution to the point spread function, and will not slow down the program (other than for the reading in of the psf image). Thus, a line of length 10 on a white background of 100 x 100 pixels will not take any more time to blur or deblur than the same line on a smaller white background.
A special utility, gaussubp.exe, is also available that can create Gaussian point spread function files directly, although you may find it easier to just create your own psf images. At this stage the conditions for successfully removing defocus blur are not clear.
I have an image with “holes” in it, and/or boundaries that are not rectangular. Can I process these?
Yes, but you need to specify a void code to the bmp2ubi and ubi2bmp programs, that specifies a special RGB code (in hexadecimal) that you have reserved to signify such “void” pixels. This means that you will need to run these programs explicitly, rather than rely on the batch files above. Type bmp2ubi or ubi2bmp from the command line to view the available options.
I want to use the UnBlur engine on more general image types. Can I do this?
Sure. But you will have to do some homework into how the program works.
A sample tutorial is available. However, beware that time constraints prevented me from going into as much detail as I would have originally liked.
I want to run UnBlur on another operating system (e.g. Linux). How do I do this?
You can, but you won’t be able to make use of the batch files provided above. You may, however, be able to adapt them to your chosen shell language.
You need to have a C compiler on your system, such as CC (standard on most Unix-type systems), or the Gnu compiler GCC (which I recommend most strongly).
If you have these, then all you need to do is download the following source code file, and running the Bash shell script make_unblur