Tuesday, May 17, 2011

A New Way to Remove Moiré

 Have you ever loaded an image into your favorite photo editing software and found some really ugly striations as in the image below?   If so, you most likely have a camera sensor induced Moiré pattern.  When the subject of your image has a very fine pattern (quite often clothing material), that pattern can interact with the fine pattern of the pixel layout of your camera sensor and on occasion result  in both false color and false luminosity striations.

There have been numerous techniques to remove the color component of the Moiré pattern and some techniques (though involved) to remove the luminosity component of the Moiré pattern.   In this blog and attached screencast I am going to present an approach I have not seen posted before that provides a productive technique for removing the luminosity component of the Moiré pattern in not all yet a large number of these Moiré patterns.

This technique works in a similar fashion to noise canceling headphones.  In such headphones, an equal but opposite sound wave is introduced to effectively cancel out the noise.  The Moiré pattern is very similar to waves on the ocean and have a similar presentation on the image.  It turns out that the peak of these "waves" in each of the color channels occur slightly offset or out of phase with each other.  This allows for the opportunity to combine the color channels in such a way to often nullify the Moiré altogether.   This more or less complex math is done with a single color adjustment layer to correct the luminosity portion of the Moiré pattern.  Trust me, it feels like magic to correct such a troubling image problem by moving just a couple sliders.

The following image was provided by Randy Brogen and was the image with which I developed this technique.  Special thanks to Randy for allowing me to share his image on this blog.  Here is the before and after images side by side.  This Screencast does a step by step correction using this image:

Copyright © 2011 Randy Brogen

Following is the Screencast
A New Way to Remove Moiré  (Part 1 of 2)  Screencast

A New Way to Remove Moiré from John Wheeler on Vimeo.

Part Two of the Screencast will cover more details on this approach and is coming "soon."

Additional Notes, Tips, and Issues with this new technicque:

- This technique will not work on every luminosity component of a Moiré pattern.    This new technique requires that the peak luminosity of the Moiré pattern is physically separated (out of phase) in the color channels.  Many sensor based Moiré patterns (but not all) are of this nature
- All editing needs to be done at 100% magnification or higher or false Moiré patterns will appear spoiling any chances for a good correction
- Working with as close to the original files without compression is helpful.  Highly compressed JPEG files degrades the color content needed to phase away the Moiré pattern.
- The adjustments of this technique may slightly change the overall image luminosity so an additional Levels or Curves adjustment layer may be needed to tune up the tone.
- When "phasing out" the luminosity component of the Moiré pattern the optimum tuning point may be slightly different for different areas of the subject.  When this occurs, each uniuque section of the subject should have its own adjustment layer and mask so each  area can be independently optimized.
- The all white layer used to expose the image luminosity can actually be any neutral color solid layer (e.g. black, gray, white)
- The all white layer used to expose the image luminosity is for viewing the luminosity only.  Once the luminosity component of the  Moiré pattern has been phased away, that layer can be hidden or removed.

Following are three additional examples for correcting Moiré patterns using this new technique.

This next  image was provided by Nadine Ohara a Wedding and Event Photographer.   Nadine frequents Photo.net      Nadine's example required 3 separate zones on the suit  for correction.

Copyright © 2011 Nadine Ohara

This next image was provide by Gordon Pritchard.  His two side by side images show the results from two different de-Mosaicing algoritms used on the raw pixel data from the camera.  Details are found on his blog at http://qualityinprint.blogspot.com/2009/12/moire-part-two.html

The   Moiré pattern is evident in several portions of this image.  The new repair technique in this blog also works on this "non-fabric" subject.  It is the fine pattern of the fence that causes the issue.
Copyright © 2011 Gordon Pritchard

Focusing just of the fence, the 3 images below show from left to right, the original, corrections to the color component of Moiré, and third adding in the luminosity correction.   The color correction by itself looks pretty good, yet also correcting the luminosity component of Moiré reveals more fence detail.

Copyright © 2011 Gordan Pritchard

The last image for this blog post comes from Mike Hagen.  This is a shot through a screened window.  The screen pattern interacts with the camera sensor creating the Moiré pattern.  In the original picture, the Moiré  pattern was subtle so I increased the image saturation to make it more visible.  This also increased the challenge for repair. Again, from left to right, I show the original, corrections to the color component of Moiré, and third adding in the luminosity correction.
Image Copyright Mike Hagen - Out There Images, Inc.
Twitter @MikeJHagen

I hope you enjoyed this tutorial on "A New Way to Remove Moiré."   All constructive feedback is welcome and positive feedback is enjoyed.  Thanks for reading/viewing.

John Wheeler - JKW Consulting LLC

Friday, January 8, 2010

Detection of Over/Under Exposure in Photoshop

I found that I really enjoy the capabilities of Adobe Lightroom and Adobe Camera Raw (ACR) in their capability to just click a little icon and be able to dynamically see which pixels were over/under exposed as you made image adjustments. I have found no direct built in way to do the same in Photoshop. I am somewhat surprised that Adobe has not included a similar piece of functionality into Photoshop.

After searching the internet I did not find any real equivalent solution. The closest I found was various incantations using either the Layers or Curves adjustment sliders neither which would show dynamic results. It was time for some home brew solutions.

I developed about a half dozen ways to dynamically detect and display the over/under exposed pixels in Photoshop and will initially share one of them below (otherwise the post gets too long). First though, we need to define what is over and under exposed. For the purpose of this post a simplified definition would be when any 8 bit pixel reaches its min value of 0 or its max value of 255. An even simpler definition would be when all three channels of an 8 bit RGB image reach a min of 0,0,0 or a max of 255,255,255 (Pretty much the same as when the gray level reaches 0 or 255). This method described below works on this last simplified definition and is similar to what Lightroom and ACR.

Here is a small sample of a Colorado sunset where I purposely set both underexposed and overexposed area.

Here is the same picture with a single added blend layer that shows the over exposures in "red" and the under exposures in "cyan". These "red" and "cyan" areas will dynamically grow and shrink as you make image adjustments in Photoshop so you can tune in your adjustments just like in Lightroom or ACR.

Note that this single blend layer described below should always be the top layer in your layer stack in Photoshop to work correctly (since you do not want it to be a permanent part of your picture). I use Photoshop CS4 yet this method should work with any version that supports an "Invert" adjustment layer and "Blend If" options

Now for simple step by step cooking instructions.

1) Make sure your "Layers" panel is displayed through the tool command
"Window > Layers" and open an image file on which you want to try this method. Having pre-existing layers is just fine.

Click the top layer so when we add the Invert layer it will be inserted at the top of your Layer Stack

2) Add an "Invert" adjustment layer through the menu:
"Layer > Layer Adjustment Layer > Invert..."

You can accept the default options in the "New Layer" dialog box that pops up or preferably type in a name such as "Over/Under Exposure Detector". Click "OK"

Your image will look pretty odd right now with inverted colors. My sunset became a surreal blue.

3) Bring up the "Layer Style" dialog box with the tool command
"Layer > Layer Style > Blending Options..."

4) Only 5 sub-steps in this Layer Style dialog box and your done!
a) Deselect the "R" channel in the Advanced Blending section
b) With the "This Layer" sliders in the "Blend If" section drag the black triangle almost all the way to the right
c) Now drag the white triangle all to the left
d) Finish dragging the black triangle all the way to the right
e) Click "OK"

5) Done (or Voila) and enjoy the feast. You should now be able to make changes to your image any way you want in Photoshop and this detection layer should dynamically show you over/under exposed pixels. By clicking the detection layer's "eye" icon you can toggle this detection on and off just like in Lightroom and ACR (also helps see the detected pixels). There are many sub options to play with in the Layer Style dialog box yet will leave that for discussion. Let me know if you have any problems with these instructions and I will update with fixes or clarifications.


Please provide this blog link to others that might benefit. Attribution would be appreciated if you plan to pass this technique on to others. Or if someone has posted this approach before me, let me know and I will give them attribution.  If there is interest, I will post other dynamic over/under exposure techniques
John Wheeler of JKW Consulting LLC