Hacker News new | ask | show | jobs
by unconed 135 days ago
Sorry but this post is the blind leading the blind, pun intended. Allow me to explain, I have a DSP degree.

The reason the filters used in the post are easily reversible is because none of them are binomial (i.e. the discrete equivalent of a gaussian blur). A binomial blur uses the coefficients of a row of Pascal's triangle, and thus is what you get when you repeatedly average each pixel with its neighbor (in 1D).

When you do, the information at the Nyquist frequency is removed entirely, because a signal of the form "-1, +1, -1, +1, ..." ends up blurred _exactly_ into "0, 0, 0, 0...".

All the other blur filters, in particular the moving average, are just poorly conceived. They filter out the middle frequencies the most, not the highest ones. It's equivalent to doing a bandpass filter and then subtracting that from the original image.

Here's an interactive notebook that explains this in the context of time series. One important point is that the "look" that people associate with "scientific data series" is actually an artifact of moving averages. If a proper filter is used, the blurryness of the signal is evident. https://observablehq.com/d/a51954c61a72e1ef

4 comments

"In today’s article, we’ll build a rudimentary blur algorithm and then pick it apart."

Emphasis mine. Quote from the beginning of the article.

This isn't meant to be a textbook about blurring algorithms. It was supposed to be a demonstration of how what may seem destroyed to a causal viewer is recoverable by a simple process, intended to give the viewer some intuition that maybe blurring isn't such a good information destroyer after all.

Your post kind of comes off like criticizing someone for showing how easy it is to crack a Caesar cipher for not using AES-256. But the whole point was to be accessible, and to introduce the idea that just because it looks unreadable doesn't mean it's not very easy to recover. No, it's not a mistake to be using the Caesar cipher for the initial introduction. Or a dead-simple one-dimensional blurring algorithm.

Using a caesar cypher as an intro without explaining the pro tool and framing the educational context properly is just shit pedagogy bro.

Go look up what a z-transform is, and begone.

Oh, I see. You're just an asshole.

My apologies for extending you the benefit of the doubt and distressing you thereby.

If you have an endless pattern of ..., -1, 1, -1, 1, -1, 1, ... and run box blur with a window of 2 or 4, you get ..., 0, 0, 0, 0, 0, 0, ... too.

Other than that, you're not wrong about theoretical Gaussian filters with infinite windows over infinite data, but this has little to do with the scenario in the article. That's about the information that leaks when you have a finite window with a discrete step and start at a well-defined boundary.

A binomial is exactly equal to a repeated 2 sample box blur yes. That's exactly how you construct pascal's triangle.

For filter sizes > 2, box blurs are ass.

Interesting...I've used moving averages not thinking too hard about the underlying implications. Do you recommend any particular book or resource on DSP basics for the average programmer?
> Sorry but this post is the blind leading the blind, pun intended. Allow me to explain, I have a DSP degree.

FWIW, this does not read as constructive.

It also makes no sense to me, and I also have a DSP degree. Of course moving averages (aka box blurs) filter out higher frequencies more than middle frequencies.
Homework assignment: make a bode plot of the convolution filters [1 1 1] vs [1 2 1].

Which one turns +1, -1, +1, -1, .. into all zeroes?

You ought to know this because the fourier transform of [1 0 1] is a cosine of amplitude 2 on the complex unit circle e^(i*omega), which means the DC quefrency needs to be 2 to get the zeroes to end up at nyquist.

The frequency response H(z) (= H(e^i*omega)) of [1 1 1] on the other hand will have its minimum somewhere in the middle.

Also here's a post that will teach you how to sight read the frequency response of symmetric FIR filters off the coefficients: https://acko.net/blog/stable-fiddusion/

The degree to which people defend poor scholarship and writing on HN these days is frankly pathetic.

There is nothing about that intro that is offensive. Reading comprehension ought to tell you that "pun intended" is a joke to make the bitter pill that OP wrote garbage easier to swallow.