Unfading images

This is an idea I had from looking at a bunch of old family photos I'd scanned. I managed to turn it into a 1-credit independent study in C++ to try to write a Photoshop plugin, which in turn got me my next job that lasted a little over 9 years. Idea copyright 2011 AB1JX, backdated to 1998.

I'd noticed in looking at overlaid red, green and blue histograms that in the fading of the dyes in the photographs the RGB lines mostly kept their original shape, they just got shifted. This is a Delphi program I wrote that manipulates the levels to let you line the peaks back up. It occurred to me around 6/2011 that it would probably work even better in CMYK colorspace because those are closer to the original dyes than the RGB.

Any real-world scene has large objects that cause peaks in the histograms. Those peaks in a normal color photo will mostly line up, but not when the dyes fade.

This is a Kodacolor photo from 1949 of my parents at their wedding. Notice the histograms with the shifts.

Here's the same thing after I did a quick job of lining up the peaks using the gain and offset sliders:

The peaks don't exactly line up, but if you came up with a least squares method of coming as close as possible to lining up most of them, weighted so the larger ones have more influence I think it would be pretty close. And it could be automated, probably requiring human confirmation before the final save. And it would work even better in CMYK colorspace. If it could be automated it could also be turned into a plugin for After Effects or something like that and used on film/video. I just don't know if there's anything out there that does this. I see enough unfixed old films to see that it could be useful. Maybe I could sell it to Adobe? It seems like a simple enough idea to me. I use The Gimp instead of Photoshop these days, but it doesn't do CMYK at all.

Linear Least Squares might work since it gives y = mx + b, the m would be the gain, the b the offset. The challenge is how to weight the peaks by amplitude so the largest ones have the biggest effect. Some scheme of entering more points by duplicating the higher amplitude ones to weight them? Divide the amplitudes by something, then enter each point that many times? Big peaks may overpower smaller ones at lower intensities that way though. Big peaks are big because they have more counts, amplitude is increasing x on the histogram. Worthwhile trying just raw peaks in lls. Do a crude integer first derivative run to find peaks (fast) then go from there. Nice to rename Delphi project first. (ColorFix3 ?).

August 6, 2012
Well, it's no great solution and I'm still poor. There are already commercial plugins for Photoshop that do this I'm told. Also lining up a majority of histogram peaks doesn't always work. If most of the picture had been green, like trees or grass it wouldn't have worked so well. I'm told there's more market for things to make new pictures look old than the other way around.

AB1JX / calcs