Dust problem: software solution?

Vtie

Senior Member
Messages
1,713
Reaction score
1
Location
Gent, BE
Part of my job includes the development of image processing
software for medical applications. It seems to me that some of
the tools applied there would be adaptable to the CCD dust problem,
and I am thinking of writing a small piece of software that
addresses that problem (which will be freeware). The idea is the
following:
  • At regular times, you have to shoot a "dust" image, e.g. small
aperture foto of a white wall out of focus
  • From that "dust" image, the software can build a library of dust
spots
  • The software can then apply that dust library to an actual
picture, replacing the dust pixels with the neighboring ones.
The last action can even be done in batch mode on a set of
images. The advantages would be much higher throughput (automatic)
and hopefully more reliable results.
However, I am not sure that the dust pattern is constant enough
over different exposures to make this method work (I guess one
dust image should be valid for at least 50 other ones).
So, this is my question: will this method work? If the answer
is positive, I will go ahead and write it (and share it). If not, I don't
want to waiste my time.
 
Part of my job includes the development of image processing
software for medical applications. It seems to me that some of
the tools applied there would be adaptable to the CCD dust problem,
and I am thinking of writing a small piece of software that
addresses that problem (which will be freeware). The idea is the
following:
  • At regular times, you have to shoot a "dust" image, e.g. small
aperture foto of a white wall out of focus
  • From that "dust" image, the software can build a library of dust
spots
  • The software can then apply that dust library to an actual
picture, replacing the dust pixels with the neighboring ones.
The last action can even be done in batch mode on a set of
images. The advantages would be much higher throughput (automatic)
and hopefully more reliable results.
However, I am not sure that the dust pattern is constant enough
over different exposures to make this method work (I guess one
dust image should be valid for at least 50 other ones).
So, this is my question: will this method work? If the answer
is positive, I will go ahead and write it (and share it). If not, I
don't
want to waiste my time.
--

PhotoShop has several excellent editing programs to take care of dust. It is not that simple to use "auto-software". Remember that the same dust looks different depending on the aperature, etc.

Greg Gebhardt
Jacksonville, Florida
 
PhotoShop has several excellent editing programs to take care of
dust. It is not that simple to use "auto-software". Remember that
the same dust looks different depending on the aperature, etc.
The only way I know in Photoshop to remove dust involves a manual
action for every individual dust spot on every individual image (e.g.
with the cloning tool). If you have to correct 20 spots on 50 images,
this means a lot of work and potential errors. Is that correct or is there
a better way?
The approach I mentioned in my initial post would allow one to fully
automatically process all 20 spots on 50 images, with a single
command. For large throughput situations, this may be crucial.

About the aperture, I thought of 2 possible solutions:
  • make a template "dust" image for each aperture and make sure
you correct the images with the corresponding dust template
  • shoot a "dust" image at very small aperture and create a buffer
around every dust spec to account for images at larger apertures
(having more blurred dust)

But again, I don't know whether this approach makes sense or is
worth the effort...
 
First of all make many dust shots (using same aperture). Compare them, to find out if mirror movement or anything else is moving your dust between shots. If so...

If it does´nt it still seems to me easier to get a good routine in cleaning the CCD (which I have not yet).

Alvaro
PhotoShop has several excellent editing programs to take care of
dust. It is not that simple to use "auto-software". Remember that
the same dust looks different depending on the aperature, etc.
The only way I know in Photoshop to remove dust involves a manual
action for every individual dust spot on every individual image (e.g.
with the cloning tool). If you have to correct 20 spots on 50 images,
this means a lot of work and potential errors. Is that correct or
is there
a better way?
The approach I mentioned in my initial post would allow one to fully
automatically process all 20 spots on 50 images, with a single
command. For large throughput situations, this may be crucial.

About the aperture, I thought of 2 possible solutions:
  • make a template "dust" image for each aperture and make sure
you correct the images with the corresponding dust template
  • shoot a "dust" image at very small aperture and create a buffer
around every dust spec to account for images at larger apertures
(having more blurred dust)

But again, I don't know whether this approach makes sense or is
worth the effort...
 
I like the idea, but to make it work, there are a couple of things to consider

a. At large apertures below f5.6, the amount of visible dust is nearly imperceptible (except for super large pieces of dust)

b. As the aperture gets smaller than f8, the dust starts out as a blur over an area larger than the size of the dust and becomes progressively smaller and sharper defined as the aperture decreases in size.

c. The dust map will have to be shot using a uniform white or light cream background. Colored backgrounds may introduce artifact into your program due to noise, especially on a warm day or after heavy use of the camera when CCD gets warm. Edge detection for dust will be simpler with white than with a color background, even if you reset the images to grayscale.

d. ISO used to take the background will also play a role because of the noise factor. Dust map should be made at the lowest ISO available on the camera.

e. You'll have to crank up the level such that noise becomes more visibile for the edge detection program

f. That being said, there are two methodologies to consider in writing the program

1. You can have the user shoot one dust map at the lowest ISO possible using a white background at an aperture of f8 and assume all dust specks will be smaller than what is found on the dust map. Then use the single map to make all the corrections -- down side is that small specks may not be visible at f8, but will be at f16 --> missed spots in some cases, but this is fixable in photoshop with less work

2. A more precise methodology is have the user shoot dust maps at all apertures from f4 up to f32. Then the program defines the location of dust and relative sizes for each map. Information derived from the EXIF will help the program figure out which dust map to use for each image. One may have to consider doing this at each ISO due to noise that will be created, especially above ISO 800.

g. Dust erasure methodology can do something similar to clone, or can just derive colors and intensity from adjacent pixels on all sides of the piece of dust. Center dust correction should be weighted against all pixels surrounding the piece of dust whereas edges of the correction map get higher weighting from pixels adjacent to the edge of the dust -- i.e. similar to attenuation correction on nuclear medicine SPECT or PET imaging or complex background correction methods used in quantitative nuclear medicine imaging techniques. I think this would be overkill for what you are trying to accomplish since the clone stamp or bandaid technique in photoshop works well and quickly (except bandaid technique smears when working adjacent to high contrast edges (i.e. sky adjacent to sun causes sun to bloom into adjacent area -- I suspect that the bandaid technique does something similar to what I just described).
 
Part of my job includes the development of image processing
software for medical applications. It seems to me that some of
the tools applied there would be adaptable to the CCD dust problem,
and I am thinking of writing a small piece of software that
addresses that problem (which will be freeware). The idea is the
following:
  • At regular times, you have to shoot a "dust" image, e.g. small
aperture foto of a white wall out of focus
  • From that "dust" image, the software can build a library of dust
spots
  • The software can then apply that dust library to an actual
picture, replacing the dust pixels with the neighboring ones.
The last action can even be done in batch mode on a set of
images. The advantages would be much higher throughput (automatic)
and hopefully more reliable results.
However, I am not sure that the dust pattern is constant enough
over different exposures to make this method work (I guess one
dust image should be valid for at least 50 other ones).
So, this is my question: will this method work? If the answer
is positive, I will go ahead and write it (and share it). If not, I
don't
want to waiste my time.
The method will work, if you use the dust image as a "guide" for the dust removal.

i.e. the small aperture dust pattern will be the worst case. So you use it as a list of locations that you should test for the presence of dust in the images you wish to clean. For example, if there's a point of inflection at a "dust point" in a differential of the image, use data outside the area of the high differential to fix the dust.

Suggest that the dust image should be taken at the end of a shoot. Even if it contains more dust locations than there were at the beginning of the shoot, testing the actual image at the "dust points" will hopefully keep real details from being processed away unnecessarily.

Ciao!

Joe
 
Part of my job includes the development of image processing
software for medical applications. It seems to me that some of
the tools applied there would be adaptable to the CCD dust problem,
and I am thinking of writing a small piece of software that
addresses that problem (which will be freeware). The idea is the
following:
  • At regular times, you have to shoot a "dust" image, e.g. small
aperture foto of a white wall out of focus
  • From that "dust" image, the software can build a library of dust
spots
  • The software can then apply that dust library to an actual
picture, replacing the dust pixels with the neighboring ones.
The last action can even be done in batch mode on a set of
images. The advantages would be much higher throughput (automatic)
and hopefully more reliable results.
However, I am not sure that the dust pattern is constant enough
over different exposures to make this method work (I guess one
dust image should be valid for at least 50 other ones).
So, this is my question: will this method work? If the answer
is positive, I will go ahead and write it (and share it). If not, I
don't
want to waiste my time.
--
Hermy
 
Part of my job includes the development of image processing
software for medical applications. It seems to me that some of
the tools applied there would be adaptable to the CCD dust problem,
and I am thinking of writing a small piece of software that
addresses that problem (which will be freeware). The idea is the
following:
  • At regular times, you have to shoot a "dust" image, e.g. small
aperture foto of a white wall out of focus
  • From that "dust" image, the software can build a library of dust
spots
  • The software can then apply that dust library to an actual
picture, replacing the dust pixels with the neighboring ones.
The last action can even be done in batch mode on a set of
images. The advantages would be much higher throughput (automatic)
and hopefully more reliable results.
However, I am not sure that the dust pattern is constant enough
over different exposures to make this method work (I guess one
dust image should be valid for at least 50 other ones).
So, this is my question: will this method work? If the answer
is positive, I will go ahead and write it (and share it). If not, I
don't
want to waiste my time.
--
Sound like a good plan, but you still have to clean your CCD???

Hermy
 
Vtie,

Don’t let the negative responses stop you. Some people, most, can only see problems where others, a very few, see opportunities.

“I don't like the sound and guitar music is out.”
Deca records, 1961. After hearing the Beetles music.

--
Coup
 
Much photo information, such as the aperature at which the photograph was made, is recorded with the photograph. Would it be possible to have the software read this information and adjust accordingly?
 
Vtie,

It seems silly to write an app that removes dust that's present over a long series of images. Why not just blow some air on the CCD? If you take a "dust" image and see significant dust, clean the CCD!

Any program which removes dust by sampling neighboring pixels will break down if the dust obscures important image detail. This is bound to happen sometimes.

I use a bulb style air blower to clean my CCD, and it takes less than a minute. (I just use the "bulb" shutterspeed setting and make sure my battery is fresh.) I have yet to have dust that can't be disloged with air.

Duncan C
-------------------------
PhotoShop has several excellent editing programs to take care of
dust. It is not that simple to use "auto-software". Remember that
the same dust looks different depending on the aperature, etc.
The only way I know in Photoshop to remove dust involves a manual
action for every individual dust spot on every individual image (e.g.
with the cloning tool). If you have to correct 20 spots on 50 images,
this means a lot of work and potential errors. Is that correct or
is there
a better way?
The approach I mentioned in my initial post would allow one to fully
automatically process all 20 spots on 50 images, with a single
command. For large throughput situations, this may be crucial.

About the aperture, I thought of 2 possible solutions:
  • make a template "dust" image for each aperture and make sure
you correct the images with the corresponding dust template
  • shoot a "dust" image at very small aperture and create a buffer
around every dust spec to account for images at larger apertures
(having more blurred dust)

But again, I don't know whether this approach makes sense or is
worth the effort...
 
Much photo information, such as the aperature at which the
photograph was made, is recorded with the photograph. Would it be
possible to have the software read this information and adjust
accordingly?
See "considerations" above. I already mention that the program can read the EXIF from the file to figure out all the parameters (aperture, ISO).

As a software engineer, this is a fun, challenging project to work on. One gets to learn about the format layout of the JPEG/NEF and EXIF to write the program. One gets into edge detection methodologies for using the "dust map" image. One gets into color correction and replacement methodologies by different techniques as described in "considerations." And one gets into the challenge of writing a user interface that is simple to use and easy to install on any system -- WinTel or MAC. Unfortunately, I don't have the time to learn about all these things and write the program.
But it's fun to think about.
 
It seems silly to write an app that removes dust that's present
over a long series of images. Why not just blow some air on the
CCD? If you take a "dust" image and see significant dust, clean the
CCD!
Well, obviously, you are correct that one better avoids the problem
rather than having to correct it. If you see dust, you blow it
away immediately. But what if you have been shooting images
for a full day (probably > 200 images), and afterwards it turns
out that some dust settled on the CCD which wasn't there
the previous time? In many cases, you won't easily see the dust
on the LCD previewer (or you don't have the time to look for it,
or you don't have the time somewhere in the field to stop and
blow the dust from your CCD).
Of course, armed with your blower, you will clean the CCD. But this
doesn't help the 200 important images you have taken and turn out
to have dust!
Any program which removes dust by sampling neighboring pixels will
break down if the dust obscures important image detail. This is
bound to happen sometimes.
Sure, and I agree it is a compromise. But if you have a bunch of
important images with dust on them, what else is the alternative?
 
And one gets into the challenge of
writing a user interface that is simple to use and easy to install
on any system -- WinTel or MAC.
I do my UI stuff on wXwindows, cross platform Mac, Windows, and UNIX (including Linux) from the same C source.

http://www.wxwindows.org

Ciao!

Joe
 
See "considerations" above. I already mention that the program can
read the EXIF from the file to figure out all the parameters
(aperture, ISO).
As a software engineer, this is a fun, challenging project to work
on. One gets to learn about the format layout of the JPEG/NEF and
EXIF to write the program. One gets into edge detection
methodologies for using the "dust map" image. One gets into color
correction and replacement methodologies by different techniques as
described in "considerations." And one gets into the challenge of
writing a user interface that is simple to use and easy to install
on any system -- WinTel or MAC. Unfortunately, I don't have the
time to learn about all these things and write the program.
But it's fun to think about.
By incidence, developing these kind of tools is just part of my job.
As I said in my initial post, I develop image analysis tools for medical
applications, including spot detection and removal with a weighted
pixel interpolation. Thanks btw for you excellent ideas in your previous
post.
Unfortunately, I know nothing about the NEF format and the EXIF
information set (I only deal with straight TIFF & JPEG in my job).
Is there anybody who has a data sheet about these formats or,
even better, a software development kit for them?
 
Unfortunately, I know nothing about the NEF format and the EXIF
information set (I only deal with straight TIFF & JPEG in my job).
Is there anybody who has a data sheet about these formats or,
even better, a software development kit for them?
Dave Coffin crw.c can read current compressed and uncompressed NEF files, as well as Canon raw files. License is "free for all uses".

http://www2.primushost.com/~dcoffin/

Daniel Stevens denef 0.3 has the code for reading the NEF files. It works for a variety of Nikon cameras, don't know if that includes d100. License is GPL.

http://www.cheeseplant.org/~daniel/pages/denef.html

Lutz Müller libexif 0.5.6 is your EXIF interface. License is LGPL.

http://sourceforge.net/projects/libexif

Ciao!

Joe
 
Joe,

Thanks for those development links. Do you know if the libexif library includes source, or is it purely an object library? (I don't know that site, and haven't had a chance to pull down the library yet.)

My pet project is writing a PS plug-in that lets it figure out the REAL colorspace used to take a JPEG. Right now, PS gets confused, and thinks ALL JPEGs taken by the D1 series are shot in sRGB. Nikon View can tell when images are shot with Adobe RGB, so the info to discriminate must be in the file somewhere!

Also, joe, do you know of a specification for the EXIF data? C source is good, but I could ALSO use a format specification.

Duncan C

-------------

Do you know if the
Joseph S. Wisniewski wrote:
...
Lutz Müller libexif 0.5.6 is your EXIF interface. License is LGPL.

http://sourceforge.net/projects/libexif

Ciao!

Joe
 
Joe,

Thanks for those development links. Do you know if the libexif
library includes source, or is it purely an object library? (I
don't know that site, and haven't had a chance to pull down the
library yet.)
My God! It's full of source....

(guess which movie I watched yesterday).
My pet project is writing a PS plug-in that lets it figure out the
REAL colorspace used to take a JPEG. Right now, PS gets confused,
and thinks ALL JPEGs taken by the D1 series are shot in sRGB. Nikon
View can tell when images are shot with Adobe RGB, so the info to
discriminate must be in the file somewhere!
In more than one place, I believe. Which is probably where the confusion comes from.
Also, joe, do you know of a specification for the EXIF data? C
source is good, but I could ALSO use a format specification.
http://www.exif.org/

One of the first rules of web surfing. If it sounds like an official standard, try looking for a .org website for it.

And don't miss this site, it's a must see for anyone doing homebrew digicam software.

http://gphoto.sourceforge.net/

Ciao!

Joe
 
Dust is very annoying - we've been working on a solution like the one you describe for a while now, and have the basics working. However, doing the adjustments has turned out to be non-trivial. Additional factors to the ones Mark describes below, including light falloff and radial distortion for some lenses, which varies with aperture and/or zoom, along with noise and shading due to imperfect images of the white/grey surface make it pretty difficult. The basics are working, but the adjustments are holding things up, since a significant number of spots still require manual cleanup even after the automatic removal process, which pretty much defeats the purpose.

If there is enough interest, we could release the basic program in the fairly near future - this would allow reasonable removal of the dust from NEF images if the lens, aperture and zoom are the same in the picture of the wall and the image the dust is being removed from. Drop me a line if you would be interested, and if there are enough responses, we'll bump up the priority on it.

If you continue to investigate, we've found that astrophotography is another field that encounters these problems - we've been looking at some of their solutions as well. They refer to the dust map as a "flat field" image. They also have it easier in that they have fewer variables to adjust for. :-)

Reverse-engineering the file formats is somewhat tedious since Nikon does make changes to the format for different cameras.

later!
-jeff

Jeff Blum, CEO
Glass Lantern, LLC
[email protected]
http://www.glasslantern.com
I like the idea, but to make it work, there are a couple of things
to consider

a. At large apertures below f5.6, the amount of visible dust is
nearly imperceptible (except for super large pieces of dust)

b. As the aperture gets smaller than f8, the dust starts out as a
blur over an area larger than the size of the dust and becomes
progressively smaller and sharper defined as the aperture decreases
in size.

c. The dust map will have to be shot using a uniform white or light
cream background. Colored backgrounds may introduce artifact into
your program due to noise, especially on a warm day or after heavy
use of the camera when CCD gets warm. Edge detection for dust will
be simpler with white than with a color background, even if you
reset the images to grayscale.

d. ISO used to take the background will also play a role because of
the noise factor. Dust map should be made at the lowest ISO
available on the camera.

e. You'll have to crank up the level such that noise becomes more
visibile for the edge detection program

f. That being said, there are two methodologies to consider in
writing the program

1. You can have the user shoot one dust map at the lowest ISO
possible using a white background at an aperture of f8 and assume
all dust specks will be smaller than what is found on the dust map.
Then use the single map to make all the corrections -- down side is
that small specks may not be visible at f8, but will be at f16 -->
missed spots in some cases, but this is fixable in photoshop with
less work

2. A more precise methodology is have the user shoot dust maps at
all apertures from f4 up to f32. Then the program defines the
location of dust and relative sizes for each map. Information
derived from the EXIF will help the program figure out which dust
map to use for each image. One may have to consider doing this at
each ISO due to noise that will be created, especially above ISO
800.

g. Dust erasure methodology can do something similar to clone, or
can just derive colors and intensity from adjacent pixels on all
sides of the piece of dust. Center dust correction should be
weighted against all pixels surrounding the piece of dust whereas
edges of the correction map get higher weighting from pixels
adjacent to the edge of the dust -- i.e. similar to attenuation
correction on nuclear medicine SPECT or PET imaging or complex
background correction methods used in quantitative nuclear medicine
imaging techniques. I think this would be overkill for what you are
trying to accomplish since the clone stamp or bandaid technique in
photoshop works well and quickly (except bandaid technique smears
when working adjacent to high contrast edges (i.e. sky adjacent to
sun causes sun to bloom into adjacent area -- I suspect that the
bandaid technique does something similar to what I just described).
 

Keyboard shortcuts

Back
Top