admin
Ronounours 4:49pm, 26 July 2010
Hi.
Some news about incoming features in next G'MIC release (planed for next wednesday, my birthday date :) )
I have added a new interesting filter 'Fourier Transform' which allows the users to get the frequency magnitude/phase of the current image, modify it (using the usual GIMP tools), and compute back the inverse fourier image.

The nice thing with such a filter is that it allows to remove undesired high frequencies in the image (such as pattern noise for instance).
Let me illustrate how it can be to remove an undesired pattern from this image :

train1 by Ronounours


(I took it from this French forum : www.passion-metrique.net/forums/viewtopic.php?f=11&t=..., I hope they don't mind, but the image is very nice to illustrate the problem).

So, in this image, we can clearly see a very important 'pattern noise' that we want to remove. Let us try G'MIC, and its new 'Fourier Transform' filter :)

train0 by Ronounours


It is a very simple filter with only one parameter which selects the direct or inverse Fourier transform (applying an inverse Fourier transform on an arbitrary image won't work since there are G'MIC specific informations in Fourier transformed images).

Here is the Fourier transform we obtain :

train2 by Ronounours


The important part of this image is located at the up-left portion. It shows the module of the centered image frequencies, and we clearly see that there are high-frequencies located in places other than the center. Those frequencies correspond actually to the pattern noise we are viewing on the original image. So, we just take a brush in black, and remove thes high-frequency patterns (you don't have to be very precise). After some moves, I get this :

train3 by Ronounours


You don't have to change the other parts of the Fourier image. They contain useful informations to be able to do the inverse transform, but for us, it is just like garbage data. Just for information, frequency phase is the right part of the image.

Well, we are done, we just have to invert the Fourier transform, here again by using the G'MIC Fourier transform. And we get this :

train4 by Ronounours


It's far better ! Most of the structured pattern noise have disappeared, and only some random-like noise is still in place. For this, the application of the 'Anisotropic smoothing' and 'Octave sharpening' steps (again with G'MIC :) ) can be used to get something more clean (perhaps a little bit too clean in my case..).

Here is the final result :

train5 by Ronounours


Compared to the original :

train1 by Ronounours


Also, I've done another cleaning with the same image, on my home laptop (it took me 3 minutes from scratch), in order to get this before/after image :

train_beforeafter by Ronounours



Any comment is appreciated.

Regards,

David.
rrossouw 8 years ago
David

You are an absolute star. A Million thank you's for this tool.

Regards

Riaan
PhotoComiX 8 years ago
Wow !
MOD
lylejk 8 years ago
Very much looking forward to this one David. I have both FFT and iFFT filters that I use in GIMP, but like the G'MIC interface and might make the flow easier. :)
wgoss 8 years ago
Very Nice...a new area for me........need to take some appropriate pictures to work on.....
admin
Ronounours Posted 8 years ago. Edited by Ronounours (admin) 8 years ago
Thanks for your comments..
There are very nice possibilities with this new filter, basically because the Fourier Transform has very nice properties for a lot of applications.

Here, I illustrate how to silently 'watermark' your images, using this new filter.

First, take the image you want to watermark (a high resolution is better, but for this example, I show it can work with low resolutions too) :

watermark1 by Ronounours


I compute then the Fourier Transform using G'MIC, and I get this :

watermark2 by Ronounours


Then, I simply put my watermark on the frequency module, using the GIMP paint tools :

watermark3 by Ronounours


And I compute back the image, using the Inverse Fourier Transform :

watermark4 by Ronounours


Do you see any differences ? Probably not at all. Buf if you compute again the Fourier Transform of this 'watermarked' image, you get this :

watermark5 by Ronounours


and your watermark appears (symmetrized due to the complex-valued properties of the Fourier Transform), clearly visible.

That may be a nice way of silently signing your images. Maybe I will add an extra filter in G'MIC that does all this automatically.

David.
snait 8 years ago
Wow!
admin
Ronounours 8 years ago
Another restoration example with the same technique :

tunisie_beforeafter by Ronounours
MOD
lylejk 8 years ago
That's a cool idea for water marking. Even if an image has been retouched to a greater extent, but bet this watermark could still be viewable; like a spread spectrum idea. Cool David. :)
MOD
lylejk 8 years ago
Just downloaded 1.3.9 David. Really like the watermark idea. Not sure if you were the first to come up with this technique, but still extremely cool. :)
MOD
François Collard Posted 8 years ago. Edited by François Collard (moderator) 8 years ago
I tried the Fourier transform with the locomotive, and I got a result that was even better than yours, David...
This brings me back to the great regret of my life: why didn't I study maths instead of literature?
The watermark filter is a good idea too, despite I'm not keen on everything connected to the protection of private property: it may help eliminating all those ugly visible watermarks...
admin
Ronounours 8 years ago
Well, I would be very interested to see what you get. I think I will post a message on the forum where I've borrowed the locomotive image, so that they could see what we got to achieve with free softwares :)
(Not that I think this is particularly awesome, but maybe interesting somehow).

I think also that watermarking is generally useless, but as many watermarking techniques are based on spectral analysis and Fourier transform, this may be a way to see at least if an image has been watermarked or not.
MOD
François Collard Posted 8 years ago. Edited by François Collard (moderator) 8 years ago
Even better, but not marvelous either. I got nearly the same pattern as yours, but I applied also auto levels and used deconvolution (Tikhonov regularization) instead of Octave sharpening.
You can see it here:
(Good news: Orange is not banned on this forum like on Gimp Users).
wgoss 8 years ago
Francois....
Why not list the steps you used for dummies like me.....maybe to much math (engineering) and not enough literature........
MOD
François Collard Posted 8 years ago. Edited by François Collard (moderator) 8 years ago
I did exactly the same as David:
- G'mic - Spectral handling - Fourier transform - direct
- Edit the top rectangle of the image the same way as David. Keep the central rectangle and mask all other whiter lines and dots in black. Hold Shift for straight lines.
- G'mic - Spectral handling - Fourier transform - inverse. You should get an image nearly without print pattern. If not enough, cancel gmic and fine-tune previous step.
- G'mic - Enhancement - anisotropic smoothing. Default settings.
- Auto levels
- G'mic - Enhancement - Deconvolution - Tikhonov regularization. Add some smoothing, because deconvolution is able to recreate artifacts.
wgoss 8 years ago
But , as I was asked, how did they get from the gmic Fourier transform direct to some image that is being edited....did we apply as a layer or what???

In effect we are using GMIC twice but what happened between.....this is a different way of using GMIC.....
MOD
François Collard Posted 8 years ago. Edited by François Collard (moderator) 8 years ago
The image is transformed by Fourier transform so you can easily access the components of the print pattern and mask them, then reconstructed without the pattern, that has been masked. No layer here. The image image data are still present in the grayish transition state you edit, but distributed in a different way, so that the periodic part of the image is isolated and editable. Try with an image with random noise only (scanned negative with silver grains): you will get only the rectangle with the cross, not the outer rectangles.
As for the exact mathematical detailed process, my high school memories are too old to help me understand the details:
en.wikipedia.org/wiki/Fourier_transform
that is why I complained about not having studied math enough...
(David can correct my mistakes).
wgoss 8 years ago
So he opens an image...
He then Runs GMIC-Fourier transform direct ....
Which closes GMIC leaving the Gray Image....
He then paints as required.....
He then opens and selects GMIC-Fourier transform inverse.....
Now closes GMIC and has a big Gray blob......

Some where the image got lost.......
MOD
François Collard 8 years ago
If you get a blob, it means you painted over some important image information. Carefully look at David's sample and don't paint the central rectangle.
admin
Ronounours 8 years ago
Yes, the central rectangle contains the low frequency informations, which *must* be preserved (most of the useful image informations are contained here).
wgoss 8 years ago
I got it......He was just using too much paint brush......
henryneu 8 years ago
Thanks very much for this filter and this tutorial!

I'm here because someone sent me 50 scans of important (for me) historical photos from an old printed document. He didn't activate the descreening filter on the scanning s/w, so there are moire patterns everywhere. The original document is no longer available...

I _think_ the filter and the method outlined here can be used for descreening. (That is, I guess, descreening=~"removing pattern noise".) But I cannot find anything specific reference to confirm this.

I did an initial test following the method and, indeed, the moiré patterns were greatly diminished. Excellent!

My questions:

1) Is this filter indeed effective for -- and intended to-- do descreening?

2) Is there anything to be added to the tutorial to make it more specific to descreening?

3) If the idea is to eliminate all the non-central patterns seen in the transformed image, could this be further automated by providing a user selection rectangle to choose the central pattern and then the s/w could automatically "paint-out" the non-central patterns? (Or am I completely misunderstanding the point of modifying the transformed data?)

4) Any advice about when in the workflow of cleaning up old photos it is best to apply descreening? First?

TIA,

henry
Mahvin Posted 8 years ago. Edited by Mahvin (member) 8 years ago
I tried this tutorial with 1.4.7.3 using the same image and it didn't work. The transform results in one long image, instead of what is shown above. When editing this image and transforming a second time, the image becomes even longer. Height exceeding width to an extreme, and does not resemble anything that results from the tutorial

UPDATE: Changing the image from grayscale to RGB mode seemed to make a difference for me.

Added a softened PhotoIllustration filter touch to blend. Looks fantastic!
train by Mahvin
henryneu 8 years ago
Mahvin:

I tried applying the technique to a series of similar photos. For reasons I have not yet understood, some worked exactly in parallel to the tutorial, but in some cases the transformation resulted in an empty frame. The images are grayscale. I tried both RGB and grayscale mode, but this didn't seem to help in those cases that failed. I compared Image Properties for successful and failing cases, but I couldn't see any fundamental differences. Failing cases could have been a bit larger, but seems unlikely to make a difference.

henry
Mahvin Posted 8 years ago. Edited by Mahvin (member) 8 years ago
It's highly possible that by my changing the mode to RGB, it falsely led me to think it was what made the difference in obtaining success. When I installed a fourier plug-in from the GIMP Registry, there was a tutorial in the read me that required the changing of image modes from grayscale to RGB, so when I attempted just that using G'MIC, it worked.

Another thing I should mention is that when using Fourier transform inverse, it gives a "preview not available" warning, which can falsely lead someone into thinking the filter isn't working.
henryneu 8 years ago
Hmmm, there might be some clues from using maximally verbose output and watching the console. (I'm on a Mac and it is easy to do; if you are on a PC, I'm not sure.) Otherwise, I'm wondering if there are some broad assumptions about GIMP operation that I'm missing. I have slowly come to realize, for example, that an instance of G'MIC is tied to a particular file being edited. It isn't applicable to the front-most file. Or so I'm beginning to believe.

I think it is important to be relaxed about the preview. it's a nice feature that may simply not be available for whatever reason.
PhotoComiX Posted 8 years ago. Edited by PhotoComiX (member) 8 years ago
i believe the filter suppose your image be RGB or RGBA

Should be possible modify the filter to take care to convert automatically in RGB, if the image is in another mode, but not sure if is worth the effort

You are using the gmic plugin version, and almost all gimp tool and plugin works properly only with RGB, to the point that almost all are automatically disabled (and look greyed out in the menu) if the image is in another mode.

So if was for me, the only fix would be add a note in the filter interface suggesting to convert the image in RGB before running the filter
Mahvin 8 years ago
In G'MIC, either mode of "any" image (RGB or grayscale) would display a "preview not available" message when using Fourier Transform (Inverse). So, I am not sure why that is or if it should always be the case.
admin
Ronounours 8 years ago
Could you post an image that is not working ?
Maybe there are som bugs remaining in the custom command I created for Fourier manipulation. It would help to know :)

Thanks.
Mahvin 8 years ago
David: I made several more attempts to get a bad result and it never did occur, so until I can duplicate my original issue I'm chalking this up to "user error". If it occurs again, I'll do my best to screenshot a 1200 x 25,750px image. I can say the result was similar to running a direct transform on the image twice.
henryneu 8 years ago
My experience was similar; I could not reproduce the failure.

"Pilot error?" Probably, to some degree, but thinking over the results I've noticed what are to me unusual operating characteristics that could contribute. For example, the relationship of a particular instance of G'MIC to a particular image window is not clear. If each G'MIC window is tied to the frontmost image window when G'MIC was invoked, then I think that the G'MIC window should close when that image window is closed, but it doesn't seem to be that way. Just now the G'MIC window remained --and could not be closed-- plus my system got very slow. This leads me to think that the null (totally transparent) transform result screen I saw might be due to apply the FT to something other than what I intended.
henryneu 8 years ago
On a possibly related topic, On MacOS 10.6.6, I start Gimp (2.6.11), open an 5670 x 3377 RGB image, select G'MIC, choose Spectral handling --> Fourier transform, direct, and hit "apply". Meanwhile I monitor system free memory, the green section in Activity Monitor. Starting with almost 3GB free, the G'Mic progress bar quickly reaches about 60% and free memory decreases to only a few megabytes. The transform does not seem to progress further, I'm guessing, due to lack of free memory. My computer doesn't work very well, either... Maybe this image is too large for my 4GB of total memory?
Groups Beta