Matte magazine

Blog about photography, image processing and retouch.
16 апреля 2016, 4:47

How to suppress regular raster

What's the problem

Sometimes it's necessary to remove regular raster during image restoration. It's difficult to perform it using built-in Photoshop tools: there are no ready filters, dodge'n'burning each point is unacceptably long, classical frequency separation is nearly useless. When I began to study ways to solve this problem, it turned out that if you get the spectrum of spatial frequencies of the image, you get a possibility to remove without damage to the image. It's impossible to do it using built-in Photoshop tools, but Google knows plugins — 2D FFT/IFFT and it's modification RGB FFT. Both plugins performs direct and inverse Fourier transformation over the image, but I have encountered troubles:

  • When plugins restore the image of the spectrum, the color disappear;
  • When the plugin is applied to any non-background layer, the darker pixels become more transparent in all color channels after recovering from a spectrum.

It's not a problem if source image is monochrome: it's enough to place black or dark Solid Color layer below the layer with recovered image. A portion of gradation is lost — a histogram of recovered image looks like a comb. As a result, plugins solve the primary task, but one has to know how to deal with the side effects.

Solution

I have found G'MIC graphic processing framework and it's derivative gmic_gimp plugin for GIMP, also I figured out that the gmic_gimp plugin does not loose the color after inverse Fourier transformation. I've thought that using GIMP only for raster suppression is bad idea, and suddenly solution was found: engineer Sergey Scherbakov created the Photoshop connector to G'MIC, so it can be used as usual filter. Now I'll tell about how to use it.

Plugin is located in Filter → Other → Плагин FFT/IFFT. On the first run plugin will ask to set up G'MIC folder locaton.

To get spectrum from the image press Direct (1) button or key 1. To invert spectrum into image press Inverse (2) or key 2.

Unlike other filters, this plug-in only shows the control box and does nothing else on Ctrl + F. The required action is started manually. Result of direct conversion is tall grey picture like this one below. The height of this picture is equal to six times the height of the source image, width is equal to source width.

It sounds strange, but it's comfortable behaviour. Using keyboard is fast and error-proof way to control the plugin.

To remove raster pattern we need to edit the very top part of the spectrum image. The spectrum of the normal image looks like 4-rays star or so.

Spectrum of the normal image Normal image

For example of rasterized image I took a piece of local district newspaper. Click to enlarge.

There are bright spots, dots and stars around the central star on the spectrum of such image. If I mask all unwanted stars and spots with black brush, the raster will disappear after spectrum inversion.

When the spectrum editing is over, spectrum image must be saved and surely closed. Fast and reliable way to do it is to press Ctrl + S → Ctrl + W. Before running inverse FFT, we have to switch back to our source working image and select there target layer. It must be non-empty. After that it's time to start recovering image from the spectrum: Ctrl + F (or Filter → Other → Плагин FFT/IFFT) → Inverse (2). Here is the result:

Photoshop locks the file with spectrum image, for this reason plugin could not open the spectrum and will terminate with error message. In this case save and close spectrum and run plugin again.

Looks almost perfect. There are some rest of the raster and dirty spots, it's easy to remove both of them after usual spatial frequency separation. In this particular case I have also used dodge'n'burn layer shown below to remove dirt from the portrait.

I decided not to polish it upon glossy magazine standard

This is the final result.

I distribute this plugin for free, by CC-NC-ND. It works on Windows with both x86 and x64 versions of Photoshop. It was tested with CC and CC2015, but probably will work with any other version. Photoshop can ask for some libraries on startup, in this case you have to download and setup Microsoft Visual C++ 2010 Redistributable Package for x64 or x86 respectively. Plugin works using temporary file stored in %Temp% directory and require up to 1 GB of space, also it require up to 1 GB of free RAM for dealing with images larger than 3500 pixels on the longest side.

Links

9 марта 2016, 18:22

Again about blue-turns-purple issue

Few months ago I wrote about this issue and about how to deal with it. That time I suggested to tune curves in red channel. Since curves are applied to entire image, we have to draw mask over part of the image. It works well but definitely not elegant.

The Hue/Saturation adjustment layer in Color blending mode allows us to correct violet shade without masks: to do this we have to tune Blues hue to +14. Deficiency of this way is that hue shift affects on entire color tone while we need to tune only mid- and low-saturated colors. Therefore, if you shift hue, tint will disappear, but the color rendition noticeably deteriorates. To avoid this, we have to make effect of adjustment layer dependant on saturation of underlying composite channel, and well, we again have to apply the mask for that.

Applying this layer in Normal mode will make blue colors brighter, which is not easy to compensate.

So I developed special LUT in 3D LUT Creator, which solves the problem of the purple shift without settings, extra actions and side effects. This LUT corrects hue depending on the saturation and maintains tonal unity. The impact of the Color Lookup adjustment layer depends on the transparency of the layer. It's clearly itself, and is automation-ready. That's how it looks on waveform, histogram and vectoroscope:

The more I use this software, the more I graterful to it's developer Oleg Sharonov. I don't need 3DLC every day, but I have nothing to replace it with when I do.

This is the LUT control points over a histogram of the real-world image shown above. Dense areas of white points show where the color of sky and river is.

Note that color of the sky and river is not exactly blue. Nevertheless color of the sky isn't as realistic as it should be — the purplish shade is quite noticeable. To correct it, I shifted low- and mid-saturated blues to cyan, and also slightly shifted cyans to emerald zone for color consistency.

Vectoroscope shows that mid-saturated blue shifted to cyan, but visually everything is okay.


Actually the blue gradient is artifical object, and sky is never exactly blue. So I checked my LUT on real-world image. It was a good idea: I figured out that the first version of the LUT was designed in too wide gamut color space. For this reason mathematically mid-saturated colors were equal to very saturated colors on the real photograph, so that my LUT actually corrected nothing. I have fixed this bug in the second version of LUT, now it works as intended.

Download LUT. Free of charge, no SMS. SHA-1 checksum: cf46c83004b7d6927749d53ac87a1f888ce8e63d.

11 августа 2015, 3:56

How to repaint the car

In this article I presume that you know, why you need to change color of the object on a photograph, but don't know, how.

The most complicated and time-consuming task is to select and outline all parts of source image to be repainted. Also it's nearly impossible to automate it, especially if the object and background colors are close to each other. To outline the object I usually use Magnetic lasso tool for crude work, then I refine selection with Refine selection feature and also with usual brush in Quick Mask mode. I personally don't like to use Pen tool with Bezier curves since it requires to precisely point and drag very small point controls.

Pen tool is great, but Fitts' law hints that control's size of 5×5 pixel is too small for frequent use. And well, I'm just not an experienced user of Pen tool in Photoshop.

When the object is clipped it's time to create a layer mask. The most obvious way is to click on «Create layer mask» button, but the most realistic mask is the inverted desaturated copy of selected object with proper contrast adjustments. Idea is that the saturation of color depends on brightness. Also mirror reflections on the objects should not be affected.

This picture placed here for descriptive reasons, the actual mask is inverted:

One more thing we should keep in mind that the mirror reflections on the bright object are less contrast than on the dark one. For this reason we need an additional contrast adjustment layer, and the structure of layers will be something like this:

Curves layer adjusts contrast according to the color, blending mode for this layer is Luminosity. Colorizer layer recolors the car, the blending mode of this layer is Overlay. Since layer in Overlay mode brightens the underlying layers, the brightness of color should not be more than 50 in HSB values.

This method keeps color of reflexes and reflections of surrounding objects and doesn't force the retoucher to use tricks in Lab color space. Try to figure out which one of these photographs below is original.

Ctrl + ↓ Ранее