Pixel Color

Started by
3 comments, last by thallish 16 years, 10 months ago
Ok take a look at this image If the red outline a pixel and the one half is black and the other half is white what will the final color be? Is it even possible to come in this situation where two objects in the world 'share' the same pixel?
regards/thallishI don't care if I'm known, I'd rather people know me
Advertisement
Yes and No. Let me explain a little further...


Because the pixel is the atomic element of an image it is impossible for the physical representation (ie the screen, framebuffer, or an image file) of that pixel to contain more than one color. So no, a pixel will never *contain* more than one color.


However, there are a few cases in which more than one color will effect the contents of the physical pixel.

The simplist example is called super-sampling. Supersampling is a technique which basically renders the image at some higher, virtual resolution but scales the results to a smaller, true image. Lets say you render the scene at a virtual resolution of 1280x960 and present that to a true resulution of 640x480. Using a simple box-filter, each true pixel contains the average of the coresponding 2x2 pixel block from the virtual image. Box filtering is the simplist and fastest technique, but many other filter types exists and may produce better image quality, depending on the image. Many sampling patterns also exist, some of which you may better know as FSAA, which your 3D card uses to provide better image quality.

Another example is alpha-blending, where a partially transparant color is overlaid onto an existing color. Through the use of a simple (or not-so-simple) formula, the two colors are combined. If the existing color is pure white (255,255,255) and the transparant color is is pure blue (0,0,255) with 50% transparancy the simplest color combiner (which simply averages the color components) will result in a medium shade of blue (127, 127, 255). More correct color combiners will often attempt to compensate for our eyes' varying levels of sensitivity for each of the red, green and blue components.

Multi-texturing and texture sampling can also result in 1 or more logical pixels affecting the outcome of a single physical pixel as well. Different textures can be combined in different ways (Added, subtracted, multiplied, XORed, etc) and these texels rarely match 1-to-1 with their physical pixel counterparts, so it is more often than not that several texels will influence a single pixel.


The example image you provided, would most likely be an example of super-sampling or texture sampling.

throw table_exception("(? ???)? ? ???");

Hi

Thank you for the extensive answer.
It was actually intended to be a case of a pixel overlapping
two texels, but my artwork is lacking[smile]. So would the two colors blend, so the color would be grey or would one of the colors be the dominant one?

regards/thallishI don't care if I'm known, I'd rather people know me
In general, yes, you simply use the weighted average of the texels' color values. your example seems to be a 50/50 split, so you'd just average the two. If one of the texels, lets say black, only covers 25% of the pixel, then it only contributes 25% to the final pixel. The formula would be (black * 0.25) + (white * 0.75) leaving you with a color which is a light grey, (192, 192, 192) in RGB values.

As I said, there are more advanced and correct ways of combining, but these results are often good enough and the most common. More advanced routines are generally used for image processing and the like.

throw table_exception("(? ???)? ? ???");

Ok thank you for that answer [smile]
regards/thallishI don't care if I'm known, I'd rather people know me

This topic is closed to new replies.

Advertisement