www.photomacrography.net :: View topic - Reducing moiré effects in downsizing for web posting
www.photomacrography.net Forum Index
An online community dedicated to the practices of photomacrography, close-up and macro photography, and photomicrography.
Photomacrography Front Page Amateurmicrography Front Page
Old Forums/Galleries
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Reducing moiré effects in downsizing for web posting
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.photomacrography.net Forum Index -> Macro and Micro Technique and Technical Discussions
View previous topic :: View next topic  
Author Message
rjlittlefield
Site Admin


Joined: 01 Aug 2006
Posts: 18170
Location: Richland, Washington State, USA

PostPosted: Wed Feb 06, 2013 8:47 pm    Post subject: Reducing moiré effects in downsizing for web posting Reply with quote

This month's Administrators Appreciation Award winner in the macro division was a bit trickier to process than usual.

I thought you might be interested in how I did it, since the concept is pretty general and I can't remember it being discussed in the forums here.

The image we're talking about was originally posted by daemonoropsis (Morten Aagaard) as image #3 in his topic "First season stacking, my 10 favorites + setup". Other versions and more information can be found on his website, http://mortenaagaard.com/focus-stacking/.

As it appeared in his photomacrography.net post, the image looks like this:


This image looked great to me, but I could see a problem looming.

As posted, the image was 1024 pixels wide. That made it big enough for most of even the small ommatidia to span 4 pixels or more. That's generally considered to be a safe ratio for avoiding aliasing problems.

But our front page format requires images that are only 621 pixels wide.

At that reduced size, the small ommatidia would span only about 2 pixels, and that's well known to be a recipe for disaster in the form of moiré effects. (For discussion and illustration, see "On the resolution and sharpness of digital images...".)

A quick test confirmed the problem, so I asked Morten for a copy of the full-sized image to play with.

Let's start at the beginning. Here's a crop from that full-sized image.



As you can see, it's gorgeous. Crisply delineated throughout, with uniformly sharp rendering of the ommatidia and the "fur" on neighboring surfaces. Beautiful, simply beautiful.

But when we pull that image into Photoshop and do a simple Image > Image Size... > Resample Image: "Bicubic Sharper (best for reduction)", here's what gets produced:

Bicubic Sharper


There's a significant amount of moiré in the eye, certainly much more than I'd prefer to put on our front page.

Now I grant that it's not bad compared to some of the alternatives. Here are resizings with "Bilinear" and "Nearest Neighbor (preserve hard edges)".

Bilinear


Nearest Neighbor


OK, clearly this is going in the wrong direction. Rather than sharper, what we want is smoother. Here are resizings with "Bicubic (best for smooth gradients)" [the default method] and with "Bicubic Smoother (best for enlargement)".

Bicubic [default]


Bicubic Smoother (best for enlargement)


Ironically, it's the "best for enlargement" method that actually does a better job for reducing the eye. But we can do even better than this.

The key to minimizing aliasing is to work with the original size image, filter out any spatial frequencies that cannot be represented in the final smaller image, and then do the actual reduction. By filtering the original size image, we give the filter enough information to do its job accurately.

The exact filter we need is not available in Photoshop (or if it is, I don't know where).

But a reasonable approximation is provided by Gaussian Blur with a width that corresponds to about 0.5 pixels in the reduced image.

In this case I'm producing an image of 641 pixels from a starting image that's about 5 times bigger, so I'll use a Gaussian Blur of 2.5 pixels (2.5/5 = 0.5).

When applied to the original image, the first thing we see is so badly blurred that it looks like complete junk:

original plus Gaussian Blur of 2.5 pixels


But this blurred junk version is just the pre-filtering we need to get a lot less moiré after resizing!

With this pre-filtering, here is what gets produced by "Bicubic (best for smooth gradients)" and "Bicubic Sharper (best for reduction)":

prefiltered, then Bicubic


prefiltered, then Bicubic Sharper


That last one looks pretty good, at least on the eye. There's a very small amount of moiré left, but nothing I'm motivated to go after, and in general the eye presents an appearance of sharpness that strikes me as representing well the original image.

However, when I go back and look at the rest of the fly, I'm not so happy with the overall sharpness. It strikes me as too soft, not well representing the original.

Of course moiré is not a problem on the rest of the fly, because there are no repeating patterns to make aliasing visible.

So, I can cheat ... um, "have my cake and eat it too" ... by using some simple layers and masks to merge the best rendition of the eye and the best rendition of the body, each in their respective areas.

For the eye, I like what we've done above, and for the body I like what's produced by my usual process of "Bicubic" resizing followed by Unsharp Mask of 35% at 0.3 pixels to add a bit of bite.

Here is the result of the merge:

final merged image


This may look like quite a bit of trouble, but really the process went a lot faster than it takes to tell about.

Besides, I think it's worth putting in some time to make our front page image look good.

I hope this is helpful.

--Rik
Back to top
View user's profile Send private message Visit poster's website
Peter De Smidt



Joined: 05 Jan 2012
Posts: 233

PostPosted: Wed Feb 06, 2013 9:35 pm    Post subject: Reply with quote

That's good stuff, Rik. I wonder how using better resizing methods such as Lanczos would work. http://www.faststone.org/FSViewerDetail.htm is a free editor that has more re-sizing options than Photoshop.
_________________
www.peterdesmidt.com/blog
Back to top
View user's profile Send private message Visit poster's website
Chris S.
Site Admin


Joined: 05 Apr 2009
Posts: 2815
Location: Ohio, USA

PostPosted: Wed Feb 06, 2013 10:51 pm    Post subject: Reply with quote

Excellent, Rik! So a boiled-down quick reference might be:

To avoid moiré: Before downsizing, apply Gaussian blur with a radius calculated as R = L1 * 0.5 / L2

Where R=radius; L1 = long dimension of original image; L2 = long dimension of final image.

If result softens non-moiré-prone areas, mask together a traditionally-downsized layer with a “blurred-before-downsized” layer.


Lovely!

--Chris
Back to top
View user's profile Send private message Send e-mail
DQE



Joined: 08 Jul 2008
Posts: 1653
Location: near Portland, Maine, USA

PostPosted: Thu Feb 07, 2013 8:13 pm    Post subject: Reply with quote

Rik,

In reviewing some of your previous posts on somewhat related topics, I came across a statement (which I very much support and believe):

"Sadly (and contrary to what's claimed in the article), that type of aliasing can not be corrected in post-processing either -- you're stuck with the Moiré patterns just like you're stuck with Bayer artifacts."

The URL to the previous thread is:

http://www.photomacrography.net/forum/viewtopic.php?t=2439

Search for this text string within the above older thread to find Rik's post which I excerpt above:

"Posted: Mon May 07, 2007 11:33 am"

How can I reconcile Rik's previous post with his text and demonstrations in the current thread where clear advantages are shown by post-processing images to greatly reduce Moire?

I'm sure I'm just missing something basic, but at the moment I am clinging to my long-standing belief: once sampled, the information, artifacts (and Moire) obtained by the original sampling frequency are baked in.

(I'm not trying to create controversy; I just can't reconcile what seems to almost be a paradox or at least something in that direction.)
_________________
-Phil

"Diffraction never sleeps"
Back to top
View user's profile Send private message
Chris S.
Site Admin


Joined: 05 Apr 2009
Posts: 2815
Location: Ohio, USA

PostPosted: Thu Feb 07, 2013 10:31 pm    Post subject: Reply with quote

Phil, how about this to reconcile the seeming paradox?

Moiré is difficult or impossible to remove after it is in an image, but can usually be prevented from getting into an image in the first place. In Rik’s quote from the earlier thread, he was discussing the impracticability of the former; in this thread, he presented a method for the latter.

--Chris
Back to top
View user's profile Send private message Send e-mail
rjlittlefield
Site Admin


Joined: 01 Aug 2006
Posts: 18170
Location: Richland, Washington State, USA

PostPosted: Thu Feb 07, 2013 11:50 pm    Post subject: Reply with quote

Chris S. wrote:
So a boiled-down quick reference might be:
...

Yes, that's a very good and concise summary.

DQE wrote:
How can I reconcile Rik's previous post with his text and demonstrations in the current thread where clear advantages are shown by post-processing images to greatly reduce Moire?

I'm sure I'm just missing something basic, but at the moment I am clinging to my long-standing belief: once sampled, the information, artifacts (and Moire) obtained by the original sampling frequency are baked in.

Chris S. wrote:
Moiré is difficult or impossible to remove after it is in an image, but can usually be prevented from getting into an image in the first place.

Yes, just so.

In more detail... In the current thread the high-res digital image plays the role of the "original signal", analogous to the optical image in my earlier thread. The Gaussian Blur filter that I've applied here does the same job as the AA filter on a digital sensor -- it removes high frequencies that would otherwise alias when sampled.

In other words (and linked images...), it's simple and effective to go from the original signal to a bandwidth limited signal to a non-aliased sample, but it's impossible to go from the original signal to an aliased sample and from there to a non-aliased sample.

Peter De Smidt wrote:
I wonder how using better resizing methods such as Lanczos would work.

Certainly there are a lot better resizing methods than the assortment that Photoshop provides. For downsizing, the key aspect is anti-aliasing, which basically means paying proper attention to all the pixels "in the gaps" between the positions of new samples. There's a good discussion of this and other aspects of resampling at http://pixinsight.com/doc/docs/InterpolationAlgorithms/InterpolationAlgorithms.html. Bart van der Wolf has a good illustration of many options at http://bvdwolf.home.xs4all.nl/main/foto/down_sample/down_sample.htm and http://bvdwolf.home.xs4all.nl/main/foto/down_sample/example1.htm.

One of the sources of confusion in talking about this stuff is that brief names like "Lanczos" can describe a wide range of methods, some of which are awful while others are quite good. For radical downsizing, bvdwolf.home shows that something called "Lanczos" is quite good. Meanwhile the pixinsight.com page shows that something they call "Lanczos-3" is awful. But I can easily imagine another method with the same name and most of the same math that would work very well, more like what bvdwolf.home shows. It just depends on whether that "-3" means number of lobes (potentially spanning many pixels and filling the gaps) or number of pixels (potentially leaving most of the gaps ignored). I'm pretty sure that bvdwolf.home tested a method that does the first, while pixinsight.com tested a method that does the second.

Quote:
http://www.faststone.org/FSViewerDetail.htm is a free editor that has more re-sizing options than Photoshop.

Thanks for the pointer. The name sounded familiar, so I checked my computer and discovered that I had FastStone installed at one point and then removed it. As best I recall, it did something weird with thumbnails in my Windows Explorer panels so I removed it because the bad effects outweighed the good at that time. That was quite some time ago so the situation has probably changed.

--Rik
Back to top
View user's profile Send private message Visit poster's website
Peter De Smidt



Joined: 05 Jan 2012
Posts: 233

PostPosted: Fri Feb 08, 2013 9:50 am    Post subject: Reply with quote

Rik,

Thanks for the links. I'll definitely check them out. I mainly do 4x5 photography, and downsizing the hi-res files in Photoshop down to web sizes doesn't work very well. A friend recently recommended Faststone. I tried it on your fly image, and it did do a better job than with the straight re-sizing method in Photoshop.
_________________
www.peterdesmidt.com/blog
Back to top
View user's profile Send private message Visit poster's website
DQE



Joined: 08 Jul 2008
Posts: 1653
Location: near Portland, Maine, USA

PostPosted: Fri Feb 08, 2013 11:55 am    Post subject: Reply with quote

Chris S. wrote:
Phil, how about this to reconcile the seeming paradox?

Moiré is difficult or impossible to remove after it is in an image, but can usually be prevented from getting into an image in the first place. In Rik’s quote from the earlier thread, he was discussing the impracticability of the former; in this thread, he presented a method for the latter.

--Chris


Chris, Rik -

Thanks for your clarifications and additional discussions.

A critical point I somehow overlooked is that we want to *resample* the original photograph in order to reduce the size of the photo (in pixels) and that this is a *new* sampling of the existing image and thus the resampling operation may benefit from prefiltering before the resampling is done. I'm not sure I've expressed this clearly but I hope it's both correct as well as reasonably clear. Now that I've written this out, I don't see how I missed these details, of course.

I am also enjoying the links Rik provided re interpolation, aliasing, and the like.

(I developed a special interest in interpolation techniques during the early years of my career (don't ask how long ago!). Perhaps I can resurrect this knowledge and attempt to tie this dormant special interest with aliasing theory, etc. It's certainly an interesting set of subjects.)
_________________
-Phil

"Diffraction never sleeps"
Back to top
View user's profile Send private message
rjlittlefield
Site Admin


Joined: 01 Aug 2006
Posts: 18170
Location: Richland, Washington State, USA

PostPosted: Fri Feb 08, 2013 1:04 pm    Post subject: Reply with quote

DQE wrote:
A critical point I somehow overlooked is that we want to *resample* the original photograph in order to reduce the size of the photo (in pixels) and that this is a *new* sampling of the existing image and thus the resampling operation may benefit from prefiltering before the resampling is done. I'm not sure I've expressed this clearly but I hope it's both correct as well as reasonably clear.

This sounds right to me.

Quote:
Now that I've written this out, I don't see how I missed these details, of course.

Ah, how often that happens!

I have not kept track of how many things I've written and then deleted because the writing made clear that the ideas weren't.

But trust me, the number would be embarrassingly large. Rolling Eyes

--Rik
Back to top
View user's profile Send private message Visit poster's website
Clintonwake



Joined: 13 Feb 2013
Posts: 207
Location: Australia

PostPosted: Sun Mar 31, 2013 10:06 am    Post subject: Reply with quote

Wow Rik, awesome image and information

cheers
Denis
Back to top
View user's profile Send private message
rjlittlefield
Site Admin


Joined: 01 Aug 2006
Posts: 18170
Location: Richland, Washington State, USA

PostPosted: Sun Mar 31, 2013 10:46 am    Post subject: Reply with quote

Thanks!

Again, the image comes from daemonoropsis (Morten Aagaard). I just tried to represent it as well as I could, in not nearly enough pixels on our front page.

--Rik
Back to top
View user's profile Send private message Visit poster's website
abpho



Joined: 17 Aug 2011
Posts: 1423
Location: Earth

PostPosted: Wed Apr 03, 2013 4:46 pm    Post subject: Reply with quote

To eliminate those moire patterns during down sizing I just do smaller reductions. From 5 to 10 times to get from the full 21MP image down to 1MP.
_________________
I'm in Canada! Isn't that weird?
Back to top
View user's profile Send private message
rjlittlefield
Site Admin


Joined: 01 Aug 2006
Posts: 18170
Location: Richland, Washington State, USA

PostPosted: Wed Apr 03, 2013 6:39 pm    Post subject: Reply with quote

abpho wrote:
To eliminate those moire patterns during down sizing I just do smaller reductions. From 5 to 10 times to get from the full 21MP image down to 1MP.

That method is attractive for its simplicity, and it's certainly a big improvement over Photoshop's one-step method. It's not quite as effective as prefiltering, however.

For illustration, here is the test image downsampled from 3000x2000 (as it came to me) to 621x414 as needed for the front page.

5 steps of Bicubic (to widths of 2189, 1598, 1166, 851, 621):


10 steps of Bicubic (to widths of 2563, 2189, 1870, 1598, 1365, 1166, 996, 851, 727, 621):


Previous result again, by prefiltering:


--Rik
Back to top
View user's profile Send private message Visit poster's website
abpho



Joined: 17 Aug 2011
Posts: 1423
Location: Earth

PostPosted: Wed Apr 03, 2013 7:00 pm    Post subject: Reply with quote

I'll see what happens next time I down size a similar shot. In my recent Robber Fly stack, the moire pattern is not visible after stepping down to the final size. Am I just not seeing it? I also only use Bilinear for my resolution changes. There was an article where someone compared the effects of the different algorithms and showed that Bilinear was the best for pretty much all occasions. Or that is what I walked away from that post. Very Happy
_________________
I'm in Canada! Isn't that weird?
Back to top
View user's profile Send private message
rjlittlefield
Site Admin


Joined: 01 Aug 2006
Posts: 18170
Location: Richland, Washington State, USA

PostPosted: Wed Apr 03, 2013 8:22 pm    Post subject: Reply with quote

abpho wrote:
I'll see what happens next time I down size a similar shot. In my recent Robber Fly stack, the moire pattern is not visible after stepping down to the final size. Am I just not seeing it?

Your robberfly looks great, as did Morten's in his original post. I think what you haven't seen yet is that your robberfly as posted is above the critical size scale where moiré hits hard, while Morten's robberfly as shrunk to fit on the front page is well below it.

Quote:
I also only use Bilinear for my resolution changes. There was an article where someone compared the effects of the different algorithms and showed that Bilinear was the best for pretty much all occasions. Or that is what I walked away from that post. Very Happy

Well, I don't know what was written and read, but it's definitely not true that Bilinear is the best for pretty much all occasions.

Here's what happens to Morten's robberfly with 10 steps of Bilinear. (Compare to 10 steps of Bicubic as shown above.)



To illustrate my point about critical size, here's what the eye of Morten's robberfly looks like at each of those 10 steps after the original:


As you can see, it holds up just fine until the facets reach a critical size scale, and then things start to go seriously bad.

Interpolating coarse features is easy. Interpolating fine irregular features is not so easy but at least the artifacts are hard to see. Interpolating fine regular features is where the problem gets tough, and that's the topic of this thread.

--Rik
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.photomacrography.net Forum Index -> Macro and Micro Technique and Technical Discussions All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group