https://en.wikipedia.org/wiki/Bayer_filter
If you have a device that can output RAWs, you can look at a RAW image using the FOSS photo development program "Darktable". Choose "photosite color" as the "demosaic" filter to show the individual color channel values (and thereby the Bayer pattern of your camera).
But yes, after removing the filter, you have three times the number of pixels but you lost color information.
I'm not exactly sure how the edge pixels are treated, but the difference in number between pixels and photosites should be on the order of a few thousand at most.
This is obviously capturing less information than if you had a completely separate set of photosites for each pixel, but the megapixel count of cameras is nevertheless accurate.
Modern cameras sometimes come with a "pixel shift" function, which uses the image stabilization system to take 4 images each shifted one photosite from the others to construct an image where each pixel contains the information of 4 independent photosites with no sharing between the pixels.
The resolution of the final image is the same as a normal image, but the result is much clearer, and far less likely to suffer from blue/red moire.
It is quite common to have more than the "nominal" number of pixels in a sensor array. So there are extra pixels for the edges.
Nowadays they classical algorithms are being replaced by convnets that are trained on different BFA/image pairs and can get very good results -- at the cost of placing a convnet in the middle (so much higher computational cost, which can be offloaded to a GPU/AI accelerator if available).
If you want to see what a "pixel perfect" camera gives you, there are the Sigma cameras with Foveon sensors[0] or you can check the cameras that have a sensor-shift superresolution approach (some pro Olympus and Hasselblad models have this feature). Sensor-shift SR has the problem that it works best on static scenes, because it takes several images which are then later combined on a single picture, and if there's movement between the images it may introduce a few artifacts.
[0] which do full color data for every pixel, as they use silicon depth to filter wavelenth
https://www.dpreview.com/reviews/image-comparison/fullscreen...
It also makes it harder to undo the effects of the demosaicking algorithm, which may be important if you're doing things like subpixel superresolution.
All in all, the BFA is "good enough" most of the times. For the use cases where it isn't, you're either:
* Budget constrained and can't really afford not using BFA
* Able to (pay for and) use either a color wheel in front of your sensor, or go with prism + triple sensor.
* Bite the bullet and go with a "strange" color array. You'll probably need to work on the software side for demosaicing to get proper support and fix eventual artifacts.
[0] even more green! 20/36 photosites are green, 8 red 8 blue
[1] with W being white, meaning no color filter or "panchromatic cell". In theory this helps on dim light conditions.
More importantly, green is close to what your eyes perceive as luminance. This is important because you can perceive a lot more luma detail than chroma detail. This is why things like 4:2:2 sampling work.
If you read Bayer's original patent, he proposed using Y Cr Cb (luminance, colour part red, colour part blue) instead of GBR filters[0]. This would people optimal from a computer science perspective. Sadly it doesn't work physically. Sensing negative-blue and negative-red can't really be done with a simple filter.
The reason is that green actually captures much more of the luminance information, and our eyes have a much better luminance resolution than color resolution.
Tangentially, it's why the so-called YUV 420 (chroma subsampling) is so effective, where it's effectively encoding Y (luminance) data for every pixel (in a block of 4), but U/V (chrominance) only for every pair (or quad, someone correct me) of pixels.
There are examples online of pictures [1] with their luminance resolution decreased: you can immediately see the pixelation, and of their chrominance resolution decreased: you can barely tell the difference.
[1] https://en.wikipedia.org/wiki/Chroma_subsampling#/media/File...
Despite such a head start, Kodak went on to completely fail the analog-to-digital camera transition. A prime example of the Disruption Dilemma.
Edit: And there was really no feasible transition path for them anyway. The business depended on skimming a little bit for every photo taken. The main selling point of digital cameras was that you could take unlimited photos at no extra cost.
Customers aren't stupid. Even with patents, if you make the camera more expensive to account for the lost revenue on film and processing chemicals, people aren't going to buy it.
Often, the chroma samples fall on pixels in even rows and on even lines. So pixels in odd rows or on odd lines, have to borrow (interpolate) their chroma values from neighbouring pixels.