Pages: « 1 [2] 3 4 ... 7 »   Bottom of Page
 Author Topic: Is this Aliasing?  (Read 23771 times)
ejmartin
Sr. Member

Offline

Posts: 575

Quote from: crames
I used interp2d.m, found in the following set from Yaroslavsky's web site: http://www.eng.tau.ac.il/~yaro/adiplab/m-files.zip.

On real images, it can tend to create ripples (due to it being done in the Discrete Cosine Transform domain). There are ways around that - Yaroslavsky has papers on his site that address that problem, but I didn't find any matlab code for it.

Rgds,
Cliff

Which paper were you referring to (about suppressing ringing artifacts)?  I'm curious how that is done.
 Logged

emil
Jonathan Wienke
Sr. Member

Offline

Posts: 5759

Quote from: crames
Those are the actual samples. I provided a link to the interpolating code. If you don't have access to Matlab, maybe Jonathan can confirm for you that those are the actual results.

http://www.mathworks.com/products/matlab/tryit.html?ref=ml_b
 Logged

Jonathan Wienke
Sr. Member

Offline

Posts: 5759

Quote from: ejmartin
Which paper were you referring to (about suppressing ringing artifacts)?  I'm curious how that is done.

It's discussed in http://www.eng.tau.ac.il/~yaro/RecentPubli...ion_ASTbook.pdf starting on page 50.

I find it a bit curious that he's using a switchover to nearest-neighbor interpolation in conditions prone to ringing. The approach I took to prevent ringing in the natural cubic spline interpolation implementation in PixelClarity is to limit the spline's z parameter values, as defined by:
http://en.wikipedia.org/wiki/Spline_interp...e_interpolation

By limiting z to ± (maximum_value - minimum_value) / n, where n is approximately 4, the tendency of the cubic spline to ring is greatly reduced, to the point where ringing artifacts are nearly impossible to find visually. Limiting the value of z causes the spline interpolation function to behave more like a linear interpolation function in cases where z has been limited; the more closely z is adjusted toward 0, the more linear the interpolation function becomes. If you force z to 0 for all sample values, spline interpolation becomes indistinguishable from linear interpolation.

I would think that a gradual blended shift toward linear interpolation would be more elegant than simply switching to nearest-neighbor in problem areas.
 « Last Edit: January 16, 2010, 09:17:14 AM by Jonathan Wienke » Logged

crames
Full Member

Offline

Posts: 210

At the risk of belaboring the point, here's a real-world example of aliasing that's not really aliasing.

I'm sure everyone has looked at the examples at maxmax.com, comparing the stock 5D with the maxmax HotRod modification (AA filter removed).

Crops of the famous air conditioner (only green channels shown) -

Stock:

HotRod as posted by MaxMax:

HotRod with better raw conversion combined with sinc upres by 2:

Not quite so bad now is it? Still a little moire in the grill (possibly a demosaick fault), but the jaggies are gone. Jaggies does not mean aliasing.

Rgds,
Cliff
 « Last Edit: January 16, 2010, 09:36:35 AM by crames » Logged

Cliff
ejmartin
Sr. Member

Offline

Posts: 575

Quote from: crames
At the risk of belaboring the point, here's a real-world example of aliasing that's not really aliasing.

I'm sure everyone has looked at the examples at maxmax.com, comparing the stock 5D with the maxmax HotRod modification (AA filter removed).

Crops of the famous air conditioner (only green channels shown) -

Stock:

HotRod as posted by MaxMax:

HotRod with better raw conversion combined with sinc upres by 2:

Not quite so bad now is it? Still a little moire in the grill (possibly a demosaick fault), but the jaggies are gone. Jaggies does not mean aliasing.

Rgds,
Cliff

All your examples involve upsampling to smooth the image.  Presumably the image at its native resolution will always exhibit the artifacts?

Also, where does one get the RAW file for this image?
 « Last Edit: January 16, 2010, 10:29:44 AM by ejmartin » Logged

emil
joofa
Sr. Member

Offline

Posts: 485

Quote from: crames

For those who don't have access to Matlab, worry not. Please use the freely available Matlab clones such as Octave or SciLab. Just google them for their website. Octave .m files have the same syntax as Matlab so most of the times same code may be used between Matlab/Octave. However, I have to caution that sometimes the indexing operations are interpreted differently by Matlab and Octave and one gets different results without any warning.
 Logged

Joofa
http://www.djjoofa.com
crames
Full Member

Offline

Posts: 210

Quote from: ejmartin
All your examples involve upsampling to smooth the image.  Presumably the image at its native resolution will always exhibit the artifacts?

Also, where does one get the RAW file for this image?

When looking at the image in its "native resolution", you are looking at the samples of the image, not the smooth original analog input to the sampling system. The upsampling is not to smooth the image - none of the information below Nyquist if affected (or hardly). It is smoothed only to eliminate the spectral replicas that are a side-effect of sampling, to restore the original smooth image. These artifacts at native resolution are not part of the image - upsampling/interpolation/reconstruction is a way to separate the underlying image from the spectral artifacts. This is possible because the reconstruction artifacts aren't the result of higher frequencies that have been folded down and mixed with lower frequencies, as happens with "real" aliasing.

The image at its native resolution will not always exhibit the artifacts, it depends on the image content. The artifacts are mostly associated with frequencies in the upper half of the spatial frequency range.

By the way, for the air conditioner example I used the latest AMML demosaicking version of dcraw found at ojodigital.com. Nice work!

Rgds,
Cliff
 « Last Edit: January 16, 2010, 11:50:42 AM by crames » Logged

Cliff
Jonathan Wienke
Sr. Member

Offline

Posts: 5759

Quote from: crames
The upsampling is not to smooth the image - none of the information below Nyquist if affected (or hardly). It is smoothed only to eliminate the spectral replicas that are a side-effect of sampling, to restore the original smooth image. These artifacts at native resolution are not part of the image - upsampling/interpolation/reconstruction is a way to separate the underlying image from the spectral artifacts. This is possible because the reconstruction artifacts aren't the result of higher frequencies that have been folded down and mixed with lower frequencies, as happens with "real" aliasing.

What is the minimum reconstruction filter expansion ratio necessary to remove reconstruction artifacts? You've shown that a ratio of 2:1 works well; would a ratio of 3:2 work equally well? My intent is to incorporate this into my image processing program, and the smaller the expansion ratio, the less RAM and CPU time needed to process the image. What are your thoughts  regarding the smallest effective reconstruction expansion ratio?
 Logged

crames
Full Member

Offline

Posts: 210

Quote from: Jonathan Wienke
What is the minimum reconstruction filter expansion ratio necessary to remove reconstruction artifacts? You've shown that a ratio of 2:1 works well; would a ratio of 3:2 work equally well? My intent is to incorporate this into my image processing program, and the smaller the expansion ratio, the less RAM and CPU time needed to process the image. What are your thoughts  regarding the smallest effective reconstruction expansion ratio?

Good question - I was wondering that myself, but haven't looked into it. I think I will try it now.

Things start to smooth out pretty well at about 1.4 with the sine 2.04 image:

The above should show up with gamma compensation. All processing was done linear then converted to sGray in PS. Below is how it looks without gamma compensation - the defects are exaggerated:

Should probably check with some other images, too.

Rgds,
Cliff
 « Last Edit: January 16, 2010, 03:08:03 PM by crames » Logged

Cliff
Jonathan Wienke
Sr. Member

Offline

Posts: 5759

I got Octave downloaded, installed, and running. Where do I copy the matlab .m files so I can access them from octave's command prompt?
 Logged

joofa
Sr. Member

Offline

Posts: 485

Quote from: Jonathan Wienke
I got Octave downloaded, installed, and running. Where do I copy the matlab .m files so I can access them from octave's command prompt?

Hi, welcome to the world of Octave. If you are on Mac, please download the optional packages such as image processing, neural networks, optimization, control, etc. For windows users I think the default package has that.

There is an environment variable you can define for locating the .m files, which I am trying to remember now, but it must be in the help somewhere. However, an easier solution, which I do, is to just "cd DIRECTORY_NAME" to where your .m files are located and just use the function on the prompt.

EDIT: I did a quick web search and it seems like you might try the "addpath" in Octave.
 « Last Edit: January 16, 2010, 03:26:15 PM by joofa » Logged

Joofa
http://www.djjoofa.com
nma
Full Member

Offline

Posts: 147

Quote from: crames

When looking at the image in its "native resolution", you are looking at the samples of the image, not the smooth original analog input to the sampling system. The upsampling is not to smooth the image - none of the information below Nyquist if affected (or hardly). It is smoothed only to eliminate the spectral replicas that are a side-effect of sampling, to restore the original smooth image. These artifacts at native resolution are not part of the image - upsampling/interpolation/reconstruction is a way to separate the underlying image from the spectral artifacts. This is possible because the reconstruction artifacts aren't the result of higher frequencies that have been folded down and mixed with lower frequencies, as happens with "real" aliasing.

The image at its native resolution will not always exhibit the artifacts, it depends on the image content. The artifacts are mostly associated with frequencies in the upper half of the spatial frequency range.

By the way, for the air conditioner example I used the latest AMML demosaicking version of dcraw found at ojodigital.com. Nice work!

Rgds,
Cliff

Cliff,

Thanks, this is the first post that really sheds a clear light on a problem that has been discussed ad nauseum, without agreement.

It would be useful if you or someone else could discuss how raw images are really processed. When I first thought about this stuff, I naively thought that something approximating sinc reconstruction was done separately on the rgb channels, resulting in a red, blur and green image all resampled to the same grid. Of course each channel will exhibit different resolution, consistent with its sampling. I was surprised to learn (somewhere) that more ad hoc techniques were employed that supposedly yielded higher resolution, while accepting a bit of aliasing. Why isn't the basic sampling theory used in practice?
 Logged
ejmartin
Sr. Member

Offline

Posts: 575

Quote from: nma
Cliff,

Thanks, this is the first post that really sheds a clear light on a problem that has been discussed ad nauseum, without agreement.

It would be useful if you or someone else could discuss how raw images are really processed. When I first thought about this stuff, I naively thought that something approximating sinc reconstruction was done separately on the rgb channels, resulting in a red, blur and green image all resampled to the same grid. Of course each channel will exhibit different resolution, consistent with its sampling. I was surprised to learn (somewhere) that more ad hoc techniques were employed that supposedly yielded higher resolution, while accepting a bit of aliasing. Why isn't the basic sampling theory used in practice?

If one used a simple linear filter to do the interpolation of color channels, resolution would be limited by the sampling frequency, and so would be particularly poor for R and B channels on a Bayer RGGB array.  However, image data is correlated between the color channels, and if those correlations are used one can achieve much higher resolution with much less artifacting.  No good demosaic just does a linear interpolation; and the better ones make some use of the correlations between R,G, and B data to achieve resolution near Nyquist for the full array rather than the individual color subsampled arrays.

Cliff, thanks for the vote of confidence.
 Logged

emil
BartvanderWolf
Sr. Member

Offline

Posts: 2943

Quote from: crames
Things start to smooth out pretty well at about 1.4 with the sine 2.04 image:

Hi Cliff,

Thanks for the examples (and gamma reminder).

Yes, 1.4 or 1.5 would start to prevent most visually disturbing artifacts. That's why I mentioned the Sqrt(2) factor, which for a "sine 2.0" image results in a diagonal sampling of 2 pixels/cycle and more oversampling at other angles. If Jonathan wants to use a 3:2 ratio, even better. The only visually disturbing artifact I get at Sqrt(2) are from a very slight variation in my LCD display pixel pitch on one side of the screen.

Quote
Should probably check with some other images, too.

On that note, could you give an estimate about the processing speed of this resampling filter on an RGB image? In the code sample I saw that Fourier transforms are involved, so processing time will increase significantly with size. I understand that an optimized code in e.g. C++ would also give different results than in MatLab, but even the MatLab version would give an indication (e.g. single channel pixels/second) of what to expect for an RGB image such as the MaxMax example.

Cheers,
Bart
 Logged
Sr. Member

Offline

Posts: 1730

Quote from: crames
There are a lot of threads here now in the LL forum about aliasing, anti-alias filters, foveon vs. bayer array, upsizing, downsizing, etc.

What does aliasing look like?

Regards,
Cliff
[a href=\'index.php?act=findpost&pid=324841\']I think this is a good example[/a]
 Logged

Hasselblad H4, Sinar P3 monorail view camera, Schneider Apo-digitar lenses
crames
Full Member

Offline

Posts: 210

[a href=\'index.php?act=findpost&pid=324841\']I think this is a good example[/a]

There is definitely some color aliasing going on there. It's possible that the luminance is unaliased and could be used to restore the color without aliasing. Is the raw file available?.

Cliff
 Logged

Cliff
crames
Full Member

Offline

Posts: 210

Quote from: BartvanderWolf
That's why I mentioned the Sqrt(2) factor, which for a "sine 2.0" image results in a diagonal sampling of 2 pixels/cycle and more oversampling at other angles.

Actually the diagonals are oversampled in comparison to horizontal and vertical. If you look at the FFT, you will see that there is more room in the corners for higher frequencies.

Quote
On that note, could you give an estimate about the processing speed of this re-sampling filter on an RGB image? In the code sample I saw that Fourier transforms are involved, so processing time will increase significantly with size. I understand that an optimized code in e.g. C++ would also give different results than in MatLab, but even the MatLab version would give an indication (e.g. single channel pixels/second) of what to expect for an RGB image such as the MaxMax example.

The largest image I tried was your rings1 image at 1000x1000 pixels, which took about 6.5 seconds to do a 2x interpolation (on my not-state-of-the-art pc). A limitation of the interp2d code is that it only accepts integer ratios. So to do the above series at 0.1 intervals, I had to over-interpolate by a factor of 10 (for example, interpolated by 14x for the 1.4 example), and then at the end decimate by nearest neighbor by a factor of 10. This complicates things and makes the memory requirements impractical for this kind of processing, unless you break it down and process it in blocks.

As I mentioned once before, for practical purposes a good bicubic interpolater might be good enough. In the maxmax example, PS bicubic does nearly as well as the sinc filter. But then again, it depends on what kind of other processing you will be doing later in the work flow. Reconstruction errors look really bad when you sharpen them.

Here is the uninterpolated MaxMax hot rod air conditioner to play with (in sGray):

Here is a "classic" paper by Mitchell on reconstruction: Rconstruction Filters in Computer Graphics

Cliff
 « Last Edit: January 17, 2010, 11:29:58 AM by crames » Logged

Cliff
Sr. Member

Offline

Posts: 1730

Quote from: crames

There is definitely some color aliasing going on there. It's possible that the luminance is unaliased and could be used to restore the color without aliasing. Is the raw file available?.

Cliff
It would be nice if I could upload the raw file to the forum... I will e-mail it to anyone who sends me their e-mail address. The raw file is .3FR, Hasselblad Phocus format.

I suppose I could up load it somewhere and post a link to it.
 Logged

Hasselblad H4, Sinar P3 monorail view camera, Schneider Apo-digitar lenses
BartvanderWolf
Sr. Member

Offline

Posts: 2943

Quote from: crames
Actually the diagonals are oversampled in comparison to horizontal and vertical. If you look at the FFT, you will see that there is more room in the corners for higher frequencies.

In the sample I provided earlier (post 5), there is no room in the FT beyond 64 x Sqrt(2) distance from DC. Here are the image, its top right corner zoomed in, and the FFT (the yellow rectangle in the next image is 64x64 pixels):
[attachment=19521:SineSqrt.png]
Of course there is more room in the FT, but we also know what happens with the image when we push detail to the extreme (the image turns gray at given frequencies).

Quote
The largest image I tried was your rings1 image at 1000x1000 pixels, which took about 6.5 seconds to do a 2x interpolation (on my not-state-of-the-art pc). A limitation of the interp2d code is that it only accepts integer ratios. So to do the above series at 0.1 intervals, I had to over-interpolate by a factor of 10 (for example, interpolated by 14x for the 1.4 example), and then at the end decimate by nearest neighbor by a factor of 10. This complicates things and makes the memory requirements impractical for this kind of processing, unless you break it down and process it in blocks.

Yes, or just stick to 2x. Hmm 6.5 seconds for a single 1Mpixel is not too bad, but it will become much slower at larger sizes and with 3 channels.

Quote
As I mentioned once before, for practical purposes a good bicubic interpolater might be good enough. In the maxmax example, PS bicubic does nearly as well as the sinc filter. But then again, it depends on what kind of other processing you will be doing later in the work flow. Reconstruction errors look really bad when you sharpen them.

Yes, but it wouldn't do that good with your original image (as you showed in post no. 7), which kicked of this thread and the interest in good reconstruction filters.

Quote
Here is a "classic" paper by Mitchell on reconstruction: Rconstruction Filters in Computer Graphics

A classic indeed, and the Mitchell/Netravali filter is the default for upsampling of regular images in ImageMagick.

Cheers,
Bart
 Logged
Jonathan Wienke
Sr. Member

Offline

Posts: 5759