1

I read conflicting information about the megapixel - subpixel relationship when it comes to sensors in digital cameras. I read that megapixel is number of sub pixels and I also read megapixel is number of pixels where each pixel is made out of 3 or 4 sub pixels, which one is true?

Considering the square patern of pixels in modern sensors, each pixel is made from 2 green sub pixels and 1 blue & green sub pixel. If the megapixel number means the number of sub pixels, then true pixel number is 1/4 of the megapixel number. On other hand if the megapixel is the number of true pixels, then the sub pixel number is 4x higher than megapixel number.

3 Answers3

7

A megapixel is literally 1 million pixels. There's no concept of sub-pixels (more on that in a moment).

E.g. suppose a camera has a sensor resolution of 6000 x 4000 (to make the math easy) ... that works out to 24,000,000 pixels or, stated more simply, 24 megapixels.

The sensor on a camera is technically a monochrome device. It is covered with a matrix of photo-sites which accumulate voltage as photons (which carry energy) hit the photosites. In this way you can imagine that a digital sensor works a bit like an array of very tiny solar panels that convert light to energy. A camera isn't trying to power anything with the very tiny energy levels on each photo site ... it just wants to measure the energy accumulation to estimate how much light hit that particular spot. But it doesn't have a notion of color (yet).

Color Filter Arrays

To get color, the camera needs a Color Filter Array (CFA). You could use a monochrome sensor and take three photos ... one with a "red" filter, one with a "green" filter, and one with a "blue" filter. You now have a sample measuring the amount of red, green, and blue at each pixel. But since this requires three separate exposures (and that takes time) it doesn't work well for action photography.

Bayer Matrix

The CFA of choice tends to be the Bayer Matrix. This is an array of very tiny color-filters in front of the sensor ... each tile on the array is only large enough to cover a single photosite. The tiles filter out red and blue light but allow green to pass through. The red and blue act similarly for their respective colors. In doing this, you have samples all all colors from just a single exposure.

See: Wikipedia - Bayer Matrix

This means the image collected is a monochrome image where each photosite only represents one particular color. If you read out the image and then assign the colors to each photosite (based on the bayer matrix) you'd get a mosaic image ... and that's no good. You need a way to demosaic the data to created blended color.

You could take the 2x2 cluster of pixels (traditionally two green, one red and one blue) and blend them (treating it like binning) to get a full color larger pixel. But this is not typically how the color camera works.

Demosaicing

To create blended color (e.g. green and red make yellow) the camera performs a demosaicing algorithm. This algorithm (and there are many variations on it) takes each photo-site's color and intensity level ... and compares that to the adjacent photo-sites color & intensity levels. E.g. if you have a "green" photosite, it will have adjacent "red" and "blue" photosites. The algorithm might average the intensity value of all neighboring "red" photosites and also average the intensity value of all neighboring "blue" photosites and assign those as the values of red and blue component of the RGB "pixel". In this way, even though the image started out as single-channel monochrome data ... it ends up having three color-channel RGB data for every single pixel.

See: Wikipedia - Demosaicing

As an interesting experiment, you can shot a single image in 'RAW' format for your camera and check the file size. Now open that image and export it as a 16-bit TIFF image and you'll notice the file-size roughly triples. This is because RAW files only store the single channel data ... the color is derived by doing that "averaging of the neighboring colors" trick ... whereas a TIFF image actually stores three color channels for each pixel (the color is not derived.)

Binning

There is a concept called "binning". A "binned" image means that a cluster of physical photosites are combined and treated as if they are just one photosite. For example, 2x2 binning means that a cluster 2 photosites wide by 2 photosites tall are combined (for a total of 4 photosites) and treated as-if they are just one logical photosite.

While this does reduce resolution, it also reduces noise. When "binning", you do have sub-pixels involved ... but binning is not commonly used in traditional photography.

Tim Campbell
  • 3,937
  • 12
  • 24
  • Thanks for detailed answer. By the way, is there a way to decide how to do the demosaicing? That 2x2 binning sounds to me like the best demosaicing becose each pixel then contains atleast one sub pixel ( ok ok, photosite ) of each color so there is no chroma undersampling happening. – wav scientist Jul 28 '19 at 16:33
  • 2
    @wavscientist binning isn't a very good method, because it doesn't account for the fact that sub-pixels are offset from each other. See my solution at https://stackoverflow.com/a/49062949/5987 – Mark Ransom Jul 28 '19 at 17:03
  • 1
  • Thank you. Please can you tell how is that "blend 4 photo sites/ sub pixels into single pixel" demosaicing called? I want to read about it but I dont know how ita named so I cant google it. I read the links you gave me but I didnt see this option mentiond there at all. – wav scientist Jul 28 '19 at 18:29
  • However, a megapixel rating for a monitor does tend to be based on RGB pixels... – rackandboneman Jul 29 '19 at 02:41
  • 2
    @wavscientist I would call it something like "naïve pixel binning". I don't think there is a settled official name, because it's rarely an option for anything since it really is inferior. – mattdm Jul 29 '19 at 03:48
  • Why is it inferior? It would not have any ringing, no blur, no guessing involved and no color artifacts since each pixel would contain photosite of each color. I cant think of a reason it wouldnt be the sharpest most artifact free way to do the demosaicing. – wav scientist Jul 29 '19 at 05:59
5

There is a 1:1 correspondence between photosites and pixels in the resulting image. (Or close to that, give or take some things like distortion correction.) With most cameras, these photosites are behind color filters. However, they do not really function as subpixels, because more sophisticated algorithms are used to create the color image from the raw data.

Megapixel numbers therefore both correspond to the number of photosites and to the number of full-color pixels in the typical resulting image. Because of the color filter array, captured detail is less than one would get with an unfiltered monochrome sensor. (This is true particularly color detail, but also luminance to a lesser degree. See What advantages does a pure black and white camera have over colour cameras? for some more on this.)

I think reading What does an unprocessed RAW file look like? will clear this up some for you — you can see the effect of the color filter array in action.

It's important to note that while this may have been a meaningful concern when we were talking about six megapixel cameras, we now have so many of them that it really can be thought of as an implementation detail with little practical effect. Unless you are using top-of-the-line lenses with a tripod in good lighting with perfect focus and everything else ideal, this is unlikely to be the limiting factor on actual resolution of detail anyway. See Do megapixels matter with modern sensor technology? for more on this.

mattdm
  • 143,140
  • 52
  • 417
  • 741
  • What do you mean by 1:1 ratio? Each pixel on screen must be able to show white color, you cant have white color with single colored sub pixel, you need to mix them together first and after that it cant be 1:1 ratio, it must be 4:1 sensor pixel - display pixel ratio. – wav scientist Jul 28 '19 at 10:08
  • 1
    There is an 1:1 ratio between monochrome sensor pixels and RGB pixels in the resulting image file. How that image file is displayed on a monitor is an entirely separate issue. – mattdm Jul 28 '19 at 10:10
  • How can there be 1:1 ratio? 3840x2160 image have 8294400 pixels, you need atleast 24883200 sub pixels to have 1:1 ratio, considering that the sensor has two green sub pixels per pixel then you need atleast 33177600 sub pixels. Full frame 24.2 megapixel sensor doesnt have enough sub pixels to make 1:1 ratio 3840x2160 photo, the red and blue colors are undersampled, not a 1:1 ratio. – wav scientist Jul 28 '19 at 11:00
  • @scientist I think the answer to that ca be summarized to interpolation in raw conversion – lijat Jul 28 '19 at 11:06
  • 1
    The 1:1 ratio is for monochrome sensor pixels. As Matt says, what happens after that is nothing to do with the sensor. – Philip Kendall Jul 28 '19 at 11:07
  • Ahh I see, I thought monochrome means single color when it fact it means black and white. Now it makes sense, so the sensor really is 1:1 when making black and white photos but starts heavy undersampling when making color photos. It could be said that the luminance is 1:1 but the chrominance isnt, its like chroma sub sampling used in lossy compression. – wav scientist Jul 28 '19 at 11:38
  • Well, see the RAW file link. It's not really black and white (grayscale) properly either, because if light from a certain area is predominantly red, the blue and green filtered pixels in that area will be darker. So while the luminance resolution is higher than the color resolution, it's still not perfect. None of this really changes the basics in terms of megapixel count, though. Megapixels don't represent real imaging resolution (in the "capturing detail" sense of that word) in a number of ways. – mattdm Jul 28 '19 at 14:30
  • Note that modern cameras both large and small have so many pixels that this is largely irrelevant. It's just an implementation detail. – mattdm Jul 28 '19 at 14:33
  • @wavscientist Additionally, the colors of the "R", "G", and "B" filters on the Bayer array do not correspond to the three colors used by trichromatic monitors. For more on that, please see this answer to Why are Red, Green, and Blue the primary colors of light? – Michael C Jul 29 '19 at 00:15
1

The word subpixel comes into play in the jargon of photography when we display an image. The red, green, and blue glowing components of the display, TV or computer or projection screen. In other words, the image data that comprise a pixel is fractured into three subpixels when the image is displayed.

Alan Marcus
  • 39,160
  • 3
  • 48
  • 91