News for hackers. Stuff that matters.
Re:A Pixel Is Not A Little Square (1995) [pdf] by bjourne on Friday July 26, 2019 @05:16PM (#20538392)
A pixel is a picture element. An element of a picture. Hence the name... It turns out that thinking of them as little boxes arranged in rectangular grids is very useful. Because that is how computers deal with them. Not as point samples.

The article reminds me of the many mathematical text I've read insisting on that vectors are not tuples of numbers. That thinking of them as anything other than directions with magnitudes is wrong. Technically, that might be correct but vectors-as-numbers is much more useful when calculating with them. When you get into more abstract mathematics, and your vectors contain other kinds of algebraic objects, such as polynomials, you are already so accustomed with them that you can think of them as flying burritos if you like.

When I teach graphics programming, I will continue to tell students that pixels are like little boxes.

Re:A Pixel Is Not A Little Square (1995) [pdf] by msla on Friday July 26, 2019 @05:34PM (#20538530)
> The article reminds me of the many mathematical text I've read insisting on that vectors are not tuples of numbers. That thinking of them as anything other than directions with magnitudes is wrong.

I break every mathematical object down into three things:

1. The intuition. Why do we have this concept to begin with? What underlying idea are we trying to capture?

2. The definition. These are the axioms.

3. The implementation. This includes every way to communicate the idea, from natural language words to notation to source code.

Without the intuition, you have nothing but a symbol game. It's hollow. Something with rules and notation but no deeper intuition is, arguably, chess.

Without the definitions, you can't think rigorously about your ideas and you don't know if they lead to internal contradiction. You can dump the axioms without losing the intuition; we did this with set theory at the turn of the previous century, when Russell proved that the previous axioms were inconsistent. We saved set theory without having to abandon the notion, the intuition, of sets entirely.

Without implementation, it's just thought, and you can't communicate with anyone. Moreover, without some intuition, the implementation is meaningless, because you have no cognitive frame to use to interpret it.

So the tuple of numbers is one implementation of a vector. It allows you to communicate some aspects of a vector, but without the underlying idea of what a vector means, what concept we're trying to get across, it's just a list of numbers. They might as well be box scores or something.

Re:A Pixel Is Not A Little Square (1995) [pdf] by mort96 on Saturday July 27, 2019 @03:30AM (#20540855)
There's also the case that there's a bunch of vectors you _can't_ represent as tuples of numbers. A vector with orientation but a magnitude of 0 is a completely valid vector afaik, and you could do things with it like normalizing it to get a unit vector of the same orientation, and it's not representable as a tuple.

The tuple model is extremely useful, but incomplete.

Re:A Pixel Is Not A Little Square (1995) [pdf] by nonanonymous on Saturday July 27, 2019 @10:15AM (#20542124)
Vectors with different orientation but the same magnitude are the same vector (the zero vector.) Observe that if you add a zero magnitude vector and a unit vector, the result is just the same unit vector. It follows that the normalization scheme you described can't be a function on vectors (since you can "normalize" two equal vectors but get two different results.)
Re:A Pixel Is Not A Little Square (1995) [pdf] by taejo on Saturday July 27, 2019 @12:17PM (#20542677)
> A vector with orientation but a magnitude of 0 is a completely valid vector afaik

Not by the mathematicians' definition. Maybe somewhere in physics such objects are useful, but if you formalized them you'd get something other than a vector space.

Re:A Pixel Is Not A Little Square (1995) [pdf] by dahart on Friday July 26, 2019 @11:30PM (#20540204)
> When I teach graphics programming, I will continue to tell students that pixels are like little boxes.

There’s certainly a sweet spot, where too much theoretical background takes away from learning graphics, and too little could leave students unprepared, or worse, uninterested.

It’s certainly good & fun to go through at least a little sampling theory.

You might also be interested to know the guy who wrote this paper co-founded Pixar. His graphics advice is worth careful consideration.

> It turns out that thinking of them as little boxes arranged in rectangular grids is very useful.

Do keep in mind that the shape and the arrangement are two separate things. Alvy’s paper is talking about the sample shape, but not talking about the arrangement. The grid arrangement is useful, and Alvy would agree.

> Because that is how computers deal with them. Not as point samples.

I’d be cautious drawing that line. I realize you were talking in part about grid arrangements. But computers treat samples however we teach them to. It’s uncommon and unlikely you’re writing a lot of code that truly handles pixels as finite square geometry rather than a point sample. Plus, if you’re teaching things like magnification filtering using bilinear or bicubic, then you’re already treating pixels (or perhaps texels) as point samples.

Here’s what you get when you treat pixels as squares: https://news.ycombinator.com/item?id=17845460

Re:A Pixel Is Not A Little Square (1995) [pdf] by bjourne on Saturday July 27, 2019 @10:06AM (#20542088)
> I’d be cautious drawing that line. I realize you were talking in part about grid arrangements. But computers treat samples however we teach them to. It’s uncommon and unlikely you’re writing a lot of code that truly handles pixels as finite square geometry rather than a point sample.

I thought about it and came up with a counter-example. subpixel rendering in general and ClearType in particular. The algorithm works by considering the exact arrangement of RGB squares (rectangles actually) to improve the appearance of rendered text. Theoretically subpixel rendering could increase the horizontal resolution threefold which were very useful for DPI-starved screens. Font hinting were also used to fit the text into the confines of the limited pixel grid.

Re:A Pixel Is Not A Little Square (1995) [pdf] by dahart on Saturday July 27, 2019 @11:24AM (#20542417)
> I thought about it and came up with a counter-example. subpixel rendering in general and ClearType in particular. The algorithm works by considering the exact arrangement of RGB squares (rectangles actually) to improve the appearance of rendered text.

I mostly agree, and see my other top-level comment where I called out LCD panels as having physically square pixels.

It’s a good thought, and it is correct that ClearType is considering the sub pixel arrangement of LCD elements. But also remember the arrangement of pixels isn’t Alvy’s main point, he was mainly trying to convey how to think about the shape of samples (pixels).

Even with ClearType you don’t necessarily want to integrate the sub-sub-samples of an LCD sub-pixel with a box (square) filter.

For sub-pixel rendering in general, box filtering is definitely not the best answer. Though yes, lots of people do it and get away with it all the time when sampling quality is not a high priority. Games are a good example, even as they’re improving. Treating pixels as square when sub-sampling causes ringing artifacts that can never be cured by adding more samples. This is actually a really fun thing to do with a class of graphics students because it’s kind of surprising the first time you really get it. For some nasty antialiasing problems only high quality kernels like a Gaussian will integrate sub-samples without artifacts.

Note I’m not talking about LCD sub-pixels there, just normal supersampling. The Wikipedia article on ClearType calls that “grayscale antialiasing” to distinguish it from LCD red-green-blue subpixels. But IMO that’s a bad name since grayscale antialiasing is still referring to filtering color images.

Re:A Pixel Is Not A Little Square (1995) [pdf] by jacobolus on Friday July 26, 2019 @10:06PM (#20539937)
> Because [little squares] is how computers deal with them. Not as point samples

This is not accurate. Computers generally represent raster images as arrays of numbers (where each entry in the array is called a “pixel”). There are no literal little squares involved. Some code (much of it mediocre) conceives of those arrays of numbers as representing little squares. Other code does not.

> vectors-as-numbers is much more useful when calculating with them

This is super myopic / parochial.

Mathematicians think of “vectors” as elements of an abstract vector space (i.e. anything with well-defined concepts of scalar multiplication and vector addition over some field). This is useful to them because there are many powerful theorems which work in general for any arbitrary vector space, or sometimes for any vector space over the complex number field, or sometimes for any finite-dimensional vector space, or ....

Physicists think of vectors as directed magnitudes, generally some kind of measurable physical quantity in Euclidean 3-space (or Minkowski space). This is useful because many kinds of combinations and relations of directed magnitudes can be computed can be made without reference to any specific coordinate system.

One possible representation of physicists’ vectors (or certain types of mathematicians’ vectors) is an array of numbers.

But an array of numbers by itself is a completely different type of object than a vector. There are no specific well-defined operations on a generic array of numbers; or rather, depending on what it represents there are a wide variety of operations that might be meaningful or reasonable.

There are many kinds of “calculations” which are completely abstract where thinking of vectors as arrays of numbers is unbelievably obscurantist and counterproductive. Proofs and derivations involving coordinates are almost always extremely cumbersome.

There are even many types of concrete calculations on vectors-represented-as-arrays-of-numbers where the most effective algorithm is to first convert to a different representation.

Re:A Pixel Is Not A Little Square (1995) [pdf] by gsliepen on Saturday July 27, 2019 @06:50AM (#20541391)
As a physicist myself, I find I think of vectors more often as a set of independent magnitudes for each of the coordinate system axes, than of a single magnitude with a direction. That's because in most cases, the physics just works independently in each axis. So it makes a lot of sense to treat vectors as sets of numbers.

Most calculations physicists do are the same as pure mathematicians would do. So we use for example in-product and cross-product operators to operate on vectors, without caring for the exact coordinate system used. Only when we have to come up with a final answer to a question like "what angle does the ball hit the ground and with what velocity?" will we convert our vectors into a magnitude and direction.

Re:A Pixel Is Not A Little Square (1995) [pdf] by jacobolus on Saturday July 27, 2019 @08:48PM (#20545230)
> I find I think of vectors more often as a set of independent magnitudes for each of the coordinate system axes

Interesting. This is what Hestenes calls the “coordinate virus”, http://geocalc.clas.asu.edu/pdf/MathViruses.pdf ; very often any specific coordinate system is not inherent but is some arbitrary addition to the space made for convenience in some particular calculation. It is in my opinion a mistake to think of the coordinates as primary.

> operate on vectors, without caring for the exact coordinate system used

This is the opposite of the previous statement.

Re:A Pixel Is Not A Little Square (1995) [pdf] by gsliepen on Sunday July 28, 2019 @06:27PM (#20550164)
> This is the opposite of the previous statement.

Not really. I didn't say in the first statement that a specific coordinate system was used. In most systems, it doesn't matter how you choose your coordinate system, as long as the basis is orthogonal, treating the coordinates independently of each other will work.

Re:A Pixel Is Not A Little Square (1995) [pdf] by afureta on Friday July 26, 2019 @10:49PM (#20540104)
> That thinking of them as anything other than directions with magnitudes is wrong.

Mathematicians like to think of just about everything as vectors, so that sentence seems a bit off.

Anyway, yeah, starting from abstract definitions is a great way to make a student's life hell. After all, there's a reason universities teach linear algebra twice.

Re:A Pixel Is Not A Little Square (1995) [pdf] by justanothersys on Friday July 26, 2019 @07:51PM (#20539320)
But how will your students learn to think outside the little boxes?