Hi, let me just summarize what has been found out by various people with respect to lens shading and the Raspi cameras, for the benefit of all.
Lens shading as implemented in the Raspi camera pipeline can counteract vignetting and the like. This is what it is designed for.
The color shifts people are experiencing when they change the standard lens of a v1- or v2-camera is something that can only partially be compensated by the lens shading algorithm.
The reason is a tiny microlens array in front of the sensors of of the Raspi cameras. These microlenses have a different pitch compared to the pixel array below.
This is done to enhance optical performance of the camera when the chip/microlens array is combined with a standard mobile phone lens - which feature focal lengths of 3-5 mm usually. The microlens array "guides" the incoming light perfectly onto the pixels of the sensor, even so the angle of the incoming light ray change dramatically from center to edge of the sensor.
Exchanging such a mobil lens with a substantially longer focal length (say: a standard photo lens of 50 mm) changes the optical pathway dramatically. The light falling through a single filter patch (say, a RED-filter) no longer gets focused on the red pixel alone, but also on neighbouring green and blue pixels. In technical terms, this is called crosstalk. The lens shading as implemented in the Raspi camera pipeline can not compensate this crosstalk. The crosstalk is spatially varying and the largest toward the image edges (compare the image of the red card in the post above).
In fact, the crosstalk is much more pronouned with the v2-camera, compared to the v1-camera. A number of people trying to correct the color shifts of Raspi cams fitted with other lenses found that out. Here's for example some information from a guy realizing a film scanner with Raspi hardware https://github.com/dgalland/yart/blob/master/yart.md
( - in French, use a translator). He found out that the results with the v1-sensor are better, colorwise, than with the v2-sensor.
In summary: if you need to change the optics of the Raspi cam for your project, you just will have to live with some color shifts across the image. You can not compensate this fully with the available lens shading. The remaining color shifts will be noticably smaller if you use a v1-sensor instead of a v2-sensor. If you can, redesign your optical system in such a way that you can leave the standard lens on the camera. For example, imaging a small Super-8 frame, you could use a 50 mm lens and place the camera about 200 mm away from the frame, with the lens 100 mm in front of the sensor chip - that will get you the approx. 1:1 scaling you need. Or: you could leave the standard lens on the camera and use in addition a good enlarger lens. By keeping the standard lens, the microlens array will work as designed, no color shifts will occur. Some examples of that approach can be found for example at the Kinograph forums (https://forums.kinograph.cc/