Gimp ‘dust and scratches’ filter

Photoshop (and Elements) has a terrific filter called Dust and Scratches. It looks for dots and curves on the image that are clearly noise, then removes them. This comes from dust on your lenses or on the photos you’re scanning, etc. An invaluable tool for all image cleanup work.

No such thing in the Gimp world. Search for gimp + dust + scratches and you either find the despeckle filter (which is useless, ime), or references to some 3rd-party plugin which was never compiled for windows.

The best tool I know of comes from the G’MIC plugin for Gimp. This is a must-have tool for many reasons (e.g., making lady’s portrait skin look soft and smooth), but the Remove Hot pixels option under the Repair subset is essentially the same thing as the Dust and Scratches of Photoshop.

I have not read the technical documentation, but the controls are simple: Mask size is the number of pixels at which to consider something being a “hot pixel”. Too low and you miss pixels. Too high and you lose detail in the image. Threshold is the amount of difference to require for something to be considered “hot”. Too high and you won’t change anything. Too low and you change too much. A standard approach is to start with mask size and threshold at minimum, then increase mask size until you fix all/most of the errors, then increase threshold until you stop screwing up everything else. Tip: As this is a compromise, leave the big scratches for manual work: Use the Clone and Healing tools instead.

Here is an example of a BEFORE ==> AFTER.

UPDATE: January 2016

As of the latest G’MIC plugin for Gimp, this effect has been moved to “Repair -> Remove hot pixels”

Also, try the “Repair -> Iain’s noise reduction”

Panoramas with HDR

This Memorial weekend, I got the chance to add some more raw footage to my 360deg panorama Sebago shots. Multiple rows. Wide exposures for HDR footage. The camera is a $130 cheapo, but does have manual settings, so I can control the exposure. We were gusting to 50 mph, so all the trees were moving, making it very difficult to get good shots for blending.

My rule is very simple: I am not going to spend any money on software. The tools have to be free.

This is a significant handicap, and it sure takes a lot longer to get things done.

But … can it be done?

I’ve tried all the free stuff. The best simple approach I know of is Microsoft’s ICE editor and the HDView plugin. Download ICE from here, and HDView from here

Forget the “Structured Panorama” option. It doesn’t work without special equipment afaik … it certainly doesn’t work with rough footage and variable overlaps.

The latest ICE is supposed to handle HDR, but it doesn’t work for me. So I have to merge each angle separately with another tool. (More on that elsewhere, perhaps. Basically I use FDRTools despite its ghosting limitation in the free version. You can use Gimp and layer tricks or other free tools, or Hugin itself.)

So, you drop all your photos onto ICE, wait a bit, and see what happens.

If ICE takes all your photos, you are done. Export to HDView.

If ICE cannot merge any single photo, then you are screwed. It would be wonderful if the next version of ICE allows you to manually position photos and help the matcher, but until then we need to look elsewhere.

The Hugin tool is supposed to the best open source option, and it is very impressive. It does multi-row panoramas AND HDR. Unfortunately, every time I’ve used it in the past, it was very time-consuming and very fragile. I’d spend hours working on something, make a small change, forget to save, and bang I’d blown it. I got so frustrated I refused to use the tool.

And the documentation is very limited. Also out-of-date. For example, the Stitcher tab (which produce the final output) has new buttons and controls which are not documented anyway. Grrr.

But now I decided I was going to figure it out. Develop a workable, repeatable procedure.

How to recover when Hugin loses its mind

The most frustrating thing for me about Hugin is when I take too large a step and the optimizer goes south. Or the preview window starts to show some links heading off to outer space. It usually occurs right when it gets tough, e.g., completing a 360deg connection, or doing one of those global optimizations and not noticing it went bad. Then I try and fix the problem and wind up making it worse because I don’t really know what I am doing.

Then I am stuck with a completely buggered file and I don’t know how to get back. Sure I save copies along the way, but I hate the lost work. Also, even after I step back, I am liable to repeat my error at some point.

I’ve seen no tutorials about how to do this. I suspect it is because the issue is deemed too obvious by the developers to be worth mentioning to . But with something as complex as Hugin, that isn’t true.

Well, I finally managed to recover a butchered file, and this is how I did it. For reference, this was my starting point: The Hugin preview window completely hosed and liable to crash anytime I sneezed:

The basic procedure is to keep all the control points (unless you’ve added some bad ones) and reset all the adjustments.

1) Go to the Images tab and reset all the adjustment variables. Select all the images, then click the “Reset” button hiding in the “Image Position”.

The result being that all the values the yaw, pitch, roll, X, Y and Z columns are reset to zero like so:

Note that I do have one image selected as the Anchor. This is important. Pick the one image you want as your “centerpoint”, then click the button “Anchor this image for position” (it is on the lower left in the above picture).

Now go to the optimizer tab. We are going to do baby steps. First, in the Optimize dropdown, select
the option “Positions (increment, starting from anchor). This tell the optimizer not to do a “global optimization”. Rather, it will start from the anchor, then position the anchor’s neighbors, then the neighbor’s neighbors, and so forth.

If things are really bad, you can also tell the optimizer to work on a subset of the images only. You can do this by checking and unchecking values in the tables, or you can check the “Only use control points between image selected in preview window”, then pull up your preview window and show/hide images there. Anyway, the picture below shows me ready to do my first optimization on all the images:

After a while, hugin is down optimizing. However, I still have serious problems. Look at the result! One of my control points is still messed up by 8539 something-or-others.

Pretty serious now, because there isn’t (afaik) any simpler way of starting the optimization.

To back up a second, I could also have tried to optimize using the “Align” button in the “Assistant” tab. The problem is that this can easily get stuck in error-land … get almost all the way done then close the progress window and tell you that it failed. I had been stuck in error-land when I started this operation, but now I tried the “Align” approach and it worked! Well, worked without throwing an error. Still having a few problems, as can be seen in the preview window:

However, you should always check the Assistant tab because it does tell you useful information at times. For example, now it is telling me that I have a wee spot of bother. Thank you, computer:

You can also check to see if you have some bad control points. Pull up the “Control points table”¬† (It is in the “View” menu) and scroll down, looking for bad points. (Too bad it won’t sort in order of badness.) If you see a row with a very high value, click on the row, and Hugin will show you the control points tab with the offending point. In my case, all my control points are correct, so phooey.

And now we come to the offending tab that has always eluded me before. The “Camera and Lens” tab:

What if these values have turned into garbage? In fact, they have. I’m going to select all the rows, then click the “Reset” button:

And do the optimization again. A bit better result this time ūüėČ

And in the preview window, we can see that reality is not too far away.

In that last window, I obviously have some remaining issues, as all my control points are shown as poor. Also, some links go off into space. I think the latter are ok and are caused by the fact that my images are in 360deg.

Now the optimizer has regained reality, we can step towards a better fit.¬† Check Hugin Optimize documentation to gain an understanding of what it does. For me, I can click on “Everything without translation” and run.

That is it for now. So the keys are:
(1) Reset the orientation values in the Images tab.
(2) Reset the camera data in the “camera and Lens” tab.
(3) Optimize with “Positions (increment, starting from anchor)” in the Optimizer tab.

And good luck to you.