From: davem@cs.ubc.ca (Dave Martindale) Newsgroups: rec.photo.digital Subject: Re: The Sigma-Foveon pixel rationale Date: 31 Mar 2004 08:55:26 GMT Message-ID: Originator: davem@cs.ubc.ca (Dave Martindale) John Navas writes: >>>>What is an "octagonal grid", and how does it differ from a square grid? >>>It's the same as a square grid rotated 45 degrees, and vice versa. >Oops! Plus half-cell offset of every other row: > Square "Octagonal" > X X X X X X X X > X X X X X X X > X X X X X X X X > X X X X X X X > X X X X X X X X >As a result, each cell has six neighbors, more like hexagonal than square, >which is what's probably causing the confusion. This is actually more subtle than it looks at first glance, and ASCII art is completely inadequate to show the difference between several different patterns that all look roughly like the "octagonal" pattern above. So I'll attempt to describe the difference in words. (I also have images that show the patterns; perhaps I should set up a web page with them somewhere). (1) Let's start with the square grid. Assume that the space between pixels in one scanline is 1 unit of distance, and the space between rows is also 1 unit, so the grid is truly square. In this case, any one pixel has 4 "near neighbours" 1 unit away, and 4 "far neighbours" that are sqrt(2) units away. (2) Now assume that you keep the horizontal and vertical pixel spacing the same, but shift every second row of pixels one-half pixel space to the right or left. That's what the ASCII diagram above actually does. This pattern is sometimes called "quincunx" sampling, because of the "X" shape made by a pixel and some of its neighbours. In this pattern, each pixel has 2 nearest neighbours (in the same row) 1 unit away, and 4 further neighbours that are all sqrt(5)/2 units away. Since not all neighbours are the same distance away, this isn't a true hex grid, but the difference between near and far is only 12%. So it's *close* to hex. Also note that you can see "rows" in the pattern along 3 different axes, one horizontal and the other two about 60 degrees rotated from that. (This does not seem to be how the Fuji sensor is built). (3) Now, take the square grid from #1 and rotate it 45 degrees. You get something that also looks somewhat like the "Octagonal" pattern above, but it's actually considerably different. Unfortunately, this rotated square grid also gets called "quincunx". Like the square grid, each pixel has 4 close neighbours at 1 unit and 4 far neighbours at sqrt(2). There are only 2 axes along which the pixels seem to line up, at +- 45 degrees. If you consider the points as being in horizontal rows and vertical columns, the spacing within the row is sqrt(2) and the vertical spacing between rows is sqrt(2)/2. This is the pattern used by Fuji's sensor - the rotated square grid. This is also the pattern made up of all the black squares on a chessboard. (4) Suppose you take the rotated square grid of #3 and stretch it a little vertically, compressing it a little horizontally. Make the spacing between rows sqrt(3)/2 instead of sqrt(2)/2. Make the horizontal spacing within a row 1 unit instead of sqrt(2). If you do this, you get a true hexagonal grid. Each point has 6 neighbours, and they are all 1 unit of distance away, the mark of a true hex. Also note that the only difference between this and grid #2 is that the vertical spacing is 0.87 rather than 1. (5) On the other hand, suppose you take the rotated square grid of #3, and squash it vertically while stretching it horizontally. Make the vertical row spacing 0.5 units and the horizontal spacing within one row sqrt(3) units. This is *also* a true hexagonal grid, with each point having 6 neighbours 1 unit away. But #4 and #5 are not the same hex grid. The points in #4 form lines at 0, 60, and 120 degrees. For #5, the lines are at 30, 90, and 150 degrees. So there are 4 different patterns, all with different characteristics, that all look somewhat like the "Octagonal" pattern above, and you can get any of them just by adjusting the horizontal/vertical spacing. Or you could use a spacing that doesn't fit any of the 4 cases above, which would give you something that could be described as "almost square" or "almost hexagonal". >I've been using the term "octagonal" because that's the shape of the sensors, >and because the actual grid isn't really square or hexagonal, although it's >closer to the latter, sort of a stretched hexagon. What would you call it? I'd call it quincunx, rotated square, hexagonal, or hexagonal, depending on which variant it was. I suppose "octagonal" isn't that bad a name either. >>In any case, a square grid rotated 45 degrees remains a square grid, >>with 4-way symmetry. It does not become an octagonal grid (or a >>hexagonal grid, for that matter). >The difference comes from the half-cell offsets. As described above, a rotated square grid and a hexagonal grid (2 types) are surprisingly close to one another, differing only in row/column spacing. All have the half-cell offset. But the two grids have quite different properties when used in an image sensor. The square and rotated square grids have a resolution limit that changes by 1.4X depending on the orientation of the feature with respect to the grid, the hex grid changes only 1.15X. Resampling a rotated square grid to a normal square grid is pretty simple, while resampling a hex grid to a square grid seems rather expensive. That's why I distinguish between square and hex grids. Dave