It’s an exciting time to be a camera hacker, because we are at a moment when even cheap camera hardware is starting to have high resolution sensors, and the awesome camera phones of a few years ago are now in people’s junkboxes. Lens swapping has been a feature of the art for a while now, usually taking the form of a C-mount add-on. So with a bit of 3D printing and glue, you can now make something more interesting from an AliExpress purchase or that old phone. These cameras have all the resolution and sharpness that the sensor can deliver assuming that their software isn’t too awful, but there’s a persistent problem . The photographs invariably have a pinkish tint, as reported in a recent Hackaday-featured project, just to name one. The original lens doesn’t have this problem, so what’s up?

Of course, the more astute readers are immediately thinking about IR filters. I did too, when one of my on-and-off projects had the pink tint. It’s a Samsung Galaxy Tab 3, an ancient Android 5 phone with a rather useless and gimmicky stylus, and a rather nice camera sensor. I bought a replacement camera module for it on AliExpress so I’d have something to experiment with, removed its lens assembly, and had a phone with a bare sensor peeking from the back of it. A 3D printed adjustable lens mount assembly that I’ll eventually clean up and release so any phone can have the same modification followed.
Faced with the dreaded pink when I started taking pictures, I ineptly glued an IR filter to the back of it, and awaited my perfect shots. Sadly they never came, so rather than admit defeat, I’m hoping one of you lot can help. Are any Hackaday readers in the optics business and can tell me what’s up?

At the top of this page you’ll see a picture of some plush animals in a hackerspace. It was taken under LED room lighting with the modified Galaxy Tab 3 and a decent quality Fuji C-mount lens, not a cheap security camera item. It’s hand focused as best as I could make it, but that’s not the problem with this image. Immediately you can see the pink cast, in the same way as all those other people’s projects, stronger at the edges and mostly not there in the middle.
I have an IR filter in place, so the obvious question becomes, is it a poor quality filter that’s still letting IR through, or is the pink tint from another source? If it’s from another source, is it something in the lens? Does the stock lens have some special magic?
Given that this lens is designed to be used with 8mm film and vacuum-tube TV cameras, I know it doesn’t impart a pink cast on its own, there’s no red shift at the edges from dodgy optics. It’s even easy enough to fix in software via white balance, but that’s not the point. There’s something wrong with this camera, and even though the whole project has only cost me a few quid, I’d like to know what it is. Are you the Hackaday-reading optical specialist who can help me and all those other camera hackers? The comments await your wisdom.

Googling around, I found this:
https://www.image-engineering.de/en/resources/image-quality-factors/shading
Loom at color shading.
TLDR: IR filter or pixel crosstalk from off axis illumination. The latter can be calibrated out.
https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Lens-Shading/
Thanks, that seems to explain it.
Try removing the lens, and taking a “flat” image against an evenly lit surface – Multiples, with the exposure, gain, whatever, options at varying extremes. Do the same with it completely dark (lens cap on / in a bag) – Compare them, and see if the problem persists or shifts.
I ran into similar issues, with a (cheap but not cheap) USB UVC camera that was shipped as a bare sensor board with a Mono Sony IMX678 sensor – the Sunplus USB-ISP bridge had built in LSC – Lens Shading Correction – even though there was no lens shipped with it. I managed to reverse engineer the webcams firmware and re-flash it to remove the LSC – It was unusable for me otherwise, now it’s perfect
I’ve had the same problem with an unmodified Lego “Vision Command” camera using the included software. I always assumed it was the incandescent lighting at the time because I was using it inside and the lights were always a little dim.
My guess is that lens shading correction in the ISP, rather than IR, is the culprit . Phone lenses vignette a lot and also unevenly across colour channels; hence, the phone uses a gain map which boosts red and blue colors in the periphery. Since your lens vignettes very little on such a small sensor, the boost exceeds the required amount making your edges pink. Colour crosstalk due to the microlens compensation for the stock lens’ sharp angles is also contributing. A pink ring when shooting a white card will confirm it. If the device supports it, try shooting in RAW mode.
Definitely not an “optical specialist”, but a camera buff since the 70’s. I wonder if, rather than your C-mount lens being lacking, the phone may be compensating for the failings of the stock lens. You mention that the effect is stronger at the edges. I vaguely remember some thread about the Raspberry Pi camera module, when somebody was doing a similar hack with it. If your c-mount is intended for 8 mm film I guess it’s image circle is about 5 mm, or larger. I would hazard a guess that the phone sensor is smaller. If so, that would give you a tele lens, even if it wasn’t in it’s original application, and also leave you without any (or less) edge abberrations. It would also give you a higher f-stop, but I’m sure I don’t have to tell you about that.
—
Regards, Kári.
My guess: Check for Chief Ray Angle mismatch.
I agree. These tiny cellphone sensors have CRA compensation maps to cater for the field angle changes to the edge of field, and hoe these incidence angles interact with the pixel micro lenses.
Not only that, the micro lens array sitting on top of the Bayer array is different. No amount of software trickery will make the image good because the Chief Ray Angle is completely wrong.
So the thing that really jumps out at me is that it’s not just the edges that are pink, the centre is green. The angle from the lens axis is the variable that determines the colour. Dichroic filters and anti-reflection coatings both do this as they’re very direction-dependent. As Ewald says, sensor angle effects like those due to microlenses are also significant.
To minimise these angle effects, lenses designed for digital sensors attempt to make the light hit the sensor at right angles to the surface but in compact systems like a smartphone this will be difficult. The IR filter is placed just above the sensor to take advantage of these hopefully closer-to-right-angle rays.
In your case I suspect there is still a significant angle effect, especially given the likely cost and size constraints. As Ewald says, this effect will be calibrated for and compensated away in software.
What you are seeing may be the opposite effect: the compensation for a radial colour cast that your lens does not produce!
What does the camera output when there is no lens in the system and the sensor is evenly illuminated? If you still see the effect strongly then it’s a calibration effect.
What angle of view is the lens you’re using? If it’s a telephoto lens then any (real) angle effect will be diminished.
Finally, could there be IR light leaking in? Is your 3d printed lens-mount IR transparent?
I had that exact catbus plush as a kid
Caveat: am not a camera designer, just a physicist who worked with optical systems.
Gut instinct: The camera system is tuned to correct colors for the default optical path. Changing the optics affects things like diffraction limits, ray incidence angles (mentioned above by Klaus and Raven), etc., and thereby can effect the charge conversion efficiency of the sensor for different colors. It could also have an effect on the Bayer filter response from angle of incidence (interference effects are highly angle dependent).
Probably the simplest solution: white balance correction. Just take a 50% gray card and generate a linear correction for the RGB components based on that image. This was standard practice among commercial photographers back in the early oughts. (Might still be; am not a pro photographer.)
Could go on for pages about physics of image conversion in Si sensors, but will spare everyone the agony…
Good points. As a former photo studio assistant and photographer who had to do those corrections:
Do not use a grey card, too fiddly and error prone. The color correction will work better if you put a matte white plexi acrylic or similar diffusion object onto the lens. Picture MUST be out of focus! Also must be done for each lens and for zooms for several focal lengths.
Results still may vary depending on light situations – we had the habit to just take a reference frame for every scene.
Capture1 software was the goto tool to do these corrections, no idea what or how to do it today.
I have not the slightest clue of photography/cameras but… isn’t the phone color calibrated to a specific sensor?
In prototyping and manufacturing digital cameras, I’ve found a short on the high frequency camera signal to shift the signal to purple. Possibly it acts as a node/stub filter at a specific frequency, where other colors were not bothered by it. But the other suggestions for this specific issue are more reasonable.
If you need cameras to hack on there are these nice people leaving cameras on sticks alongside the road to donate to all your maker projects. They even come with solar panels. Just make sure to ditch the rest of the electronics before you take it home. The junkware on those is nasty and you wouldn’t want it infecting your stuff.
That’s flocking devious.
Normally, this effect is caused by attaching a different lens to a sensor with a microlens array optimized for a small lens. Like cheap sensors for mobile phones. The CRA of lens and sensor do not match. The result is typically a magenta cast on the borders of the image. Note that this cast cannot be corrected by a standard lens shading compensation. The color mixing occuring at the edges of the sensor is a signal crosstalk – nothing a standard lens shading can handle
This!