qhjiang
Posts: 10
Joined: Thu May 06, 2021 12:17 pm

Pinky purple stripes and a discontinuity in the image.

Mon May 10, 2021 12:23 pm

Hello, when I used a Raspberry Pi Camera v1 or Raspberry Pi Camera v2 on the Raspberry Pi 3B+ board, there remains pinky-purple stripes and a discontinuity in the image (640*480).

When I attempt to read the RGB value of the picture, I found several interesting phenomena as follows.
1. The green value of the pinky-purple stripes is zero. I have no idea why the value of the green channel is affected. Is it caused by the CRC?
2. The white part (255, 255, 255) of the original image is not affected by the above. I am very confused that the value of the green channel is affected as stated by 1, but why the white part (255, 255, 255) is not affected as well.
3. Sometimes, stripes can be colorful, such as blue and yellow strip. But only the purple stripes appear in large areas.
4. What causes a discontinuity in the image.

Is there anyone has some ideas?
Thanks.
Attachments
399.jpg
399.jpg (63.22 KiB) Viewed 606 times
284.jpg
284.jpg (39.79 KiB) Viewed 606 times
278.jpg
278.jpg (32.91 KiB) Viewed 606 times

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11208
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pinky purple stripes and a discontinuity in the image.

Mon May 10, 2021 5:43 pm

This has been covered multiple times - it is interference on the CSI2 bus, generally because people have used a stupidly long cable to connect between the Pi and camera.
viewtopic.php?f=43&t=300009&p=1803385
viewtopic.php?f=43&t=288886&p=1746626
viewtopic.php?f=43&t=286001&p=1730815
viewtopic.php?f=43&t=240534&p=1468195
to give 4 examples.

CSI2 can correct a single error per line, but multiple errors will result in the line being discarded. Due to the Bayer pattern of the image, this means that what was

Code: Select all

B G B G B G
G R G R G R
B G B G B G
G R G R G R
becomes

Code: Select all

B G B G B G
G R G R G R
G R G R G R
but the hardware has no way to compensate for this lost line, and will interpret the G as B, and the R as G. That sort of swap will generally result in a pink/magenta image.
Any white portions of the image will have equal (and probably saturated) red, green, and blue values, so will remain white.

If you get 2 discarded lines in a frame then you effectively correct the Bayer pattern and the colours will go back to normal, but your image will now be 2 lines short.

Use short camera cables, or keep them well away from sources of interference.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

cleverca22
Posts: 3741
Joined: Sat Aug 18, 2012 2:33 pm

Re: Pinky purple stripes and a discontinuity in the image.

Mon May 10, 2021 8:32 pm

6by9 wrote:
Mon May 10, 2021 5:43 pm
but the hardware has no way to compensate for this lost line, and will interpret the G as B, and the R as G. That sort of swap will generally result in a pink/magenta image.
Any white portions of the image will have equal (and probably saturated) red, green, and blue values, so will remain white.
is there any way to know which line is missing (an err status reg?) and/or insert a dummy all-0's line?
or is that a limitation of the unicam block, and it cant be corrected for?

qhjiang
Posts: 10
Joined: Thu May 06, 2021 12:17 pm

Re: Pinky purple stripes and a discontinuity in the image.

Tue May 11, 2021 1:43 am

6by9 wrote:
Mon May 10, 2021 5:43 pm
This has been covered multiple times - it is interference on the CSI2 bus, generally because people have used a stupidly long cable to connect between the Pi and camera.
viewtopic.php?f=43&t=300009&p=1803385
viewtopic.php?f=43&t=288886&p=1746626
viewtopic.php?f=43&t=286001&p=1730815
viewtopic.php?f=43&t=240534&p=1468195
to give 4 examples.

CSI2 can correct a single error per line, but multiple errors will result in the line being discarded. Due to the Bayer pattern of the image, this means that what was

Code: Select all

B G B G B G
G R G R G R
B G B G B G
G R G R G R
becomes

Code: Select all

B G B G B G
G R G R G R
G R G R G R
but the hardware has no way to compensate for this lost line, and will interpret the G as B, and the R as G. That sort of swap will generally result in a pink/magenta image.
Any white portions of the image will have equal (and probably saturated) red, green, and blue values, so will remain white.

If you get 2 discarded lines in a frame then you effectively correct the Bayer pattern and the colours will go back to normal, but your image will now be 2 lines short.

Use short camera cables, or keep them well away from sources of interference.
Thanks for your reply. It's helpful for me. But I also have some questions as follows:
1. What is the essential reason for line loss? If the loss of the line will cause the loss of the image content or not? and why?
2. Is there any way to make sure it is certainly the reason for the line loss? And how to know the lost line is G/R or B/G line?
3. If the hardware interprets the G as B, and the R as G, the value of the green channel can't be zero. But I read the RGB values of the image, the green channel value of the purple stripe part is missing.
4. The output of the camera v2 sensor is RAW10, one packet contains four pixels. How to find the line mentioned above in the CSI2 packet?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11208
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pinky purple stripes and a discontinuity in the image.

Tue May 11, 2021 9:30 am

The essential reason for the line loss is interference - I can say that with 99.999% confidence due to the symptoms. It's either that or a partially broken sensor.

There isn't any information about which line got dropped because your image is already messed up at that point and ought to be discarded. Due to the Bayer pattern, both the lines above and below would have incomplete colour data, so you would have a minimum of a 3 line issue in your image, and quite possibly more.

CSI2 is designed for mobile applications where it needs to travel a few centimetres around the inside of a mobile phone or tablet. 30cm is really the limit under normal stuations. If you've used it on a long cable then I'm afraid that isn't the fault of the Pi or the camera module.
You can try to reduce the risk of interference by using screened cables (eg the adapters that use HDMI leads with their individually screened pairs), but you'll still have to contend with losses in the cable on both the 3V3 supply rails, and for the CSI2 signals.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

qhjiang
Posts: 10
Joined: Thu May 06, 2021 12:17 pm

Re: Pinky purple stripes and a discontinuity in the image.

Tue May 11, 2021 10:06 am

6by9 wrote:
Tue May 11, 2021 9:30 am
The essential reason for the line loss is interference - I can say that with 99.999% confidence due to the symptoms. It's either that or a partially broken sensor.

There isn't any information about which line got dropped because your image is already messed up at that point and ought to be discarded. Due to the Bayer pattern, both the lines above and below would have incomplete colour data, so you would have a minimum of a 3 line issue in your image, and quite possibly more.

CSI2 is designed for mobile applications where it needs to travel a few centimetres around the inside of a mobile phone or tablet. 30cm is really the limit under normal stuations. If you've used it on a long cable then I'm afraid that isn't the fault of the Pi or the camera module.
You can try to reduce the risk of interference by using screened cables (eg the adapters that use HDMI leads with their individually screened pairs), but you'll still have to contend with losses in the cable on both the 3V3 supply rails, and for the CSI2 signals.
Thank you, 6bu9!
I didn't make myself clear. My first question is why the interference can cause the line loss? Is it related to the differential voltage of the CSI2's data_lane? And do you have any idea about the third question "If the hardware interprets the G as B, and the R as G, the value of the green channel can't be zero. But I read the RGB values of the image, the green channel value of the purple stripe part is missing."?
Another two questions are as follows:
1. Why does the exchange of G/B or R/G always cause pinky-purple stripes? In my understanding, the result of this exchange is related to the relative relationship between the original R/B value and G value.
2. I have tried "vcgencmd set_logging level=0xc00" and "sudo vcdbg log msg" to have a look at the log as you suggested in another topic, but I don't find the line "unicam_int_callback error [0]: <something>". The log file you can find on https://drive.google.com/file/d/1R2PAQz ... sp=sharing

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11208
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pinky purple stripes and a discontinuity in the image.

Tue May 11, 2021 10:22 am

qhjiang wrote:
Tue May 11, 2021 10:06 am
I didn't make myself clear. My first question is why the interference can cause the line loss? Is it related to the differential voltage of the CSI2's data_lane?
Each CSI2 data lane has single bit error correction and multiple bit error detection built into the bitstream. If the hardware registers a multiple bit error then it has to do something, and that something has been implemented as discard the line.
qhjiang wrote:And do you have any idea about the third question "If the hardware interprets the G as B, and the R as G, the value of the green channel can't be zero. But I read the RGB values of the image, the green channel value of the purple stripe part is missing."?
Demosaicing (converting Bayer into a fully sampled image) will take context from surrounding pixels.
qhjiang wrote:Another two questions are as follows:
1. Why does the exchange of G/B or R/G always cause pinky-purple stripes? In my understanding, the result of this exchange is related to the relative relationship between the original R/B value and G value.
2. I have tried "vcgencmd set_logging level=0xc00" and "sudo vcdbg log msg" to have a look at the log as you suggested in another topic, but I don't find the line "unicam_int_callback error [0]: <something>". The log file you can find on https://drive.google.com/file/d/1R2PAQz ... sp=sharing
Sorry, to be quite honest I have no interest in investigating why or where a severely corrupted image is going wrong UNLESS you come back and say this is on the standard ~20cm FFC cable shipped with Pi cameras in a normal environment (ie not adjacent to a welding rig). Even then I'd suspect a hardware issue with one of the devices as it is not a systemic issue.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

qhjiang
Posts: 10
Joined: Thu May 06, 2021 12:17 pm

Re: Pinky purple stripes and a discontinuity in the image.

Wed May 12, 2021 7:53 am

Sorry, to be quite honest I have no interest in investigating why or where a severely corrupted image is going wrong UNLESS you come back and say this is on the standard ~20cm FFC cable shipped with Pi cameras in a normal environment (ie not adjacent to a welding rig). Even then I'd suspect a hardware issue with one of the devices as it is not a systemic issue.
Hello, 6by9. I use the standard ~20cm FFC cable shipped with Pi cameras but there may indeed be disturbances in the environment.
1. Why does the exchange of G/B or R/G always cause pinky-purple stripes? In my understanding, the result of this exchange is related to the relative relationship between the original R/B value and G value.
This problem has been bothering me for a long time. Could you please give me some advice? Thank you very much.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11208
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pinky purple stripes and a discontinuity in the image.

Wed May 12, 2021 11:17 am

qhjiang wrote:
Wed May 12, 2021 7:53 am
Sorry, to be quite honest I have no interest in investigating why or where a severely corrupted image is going wrong UNLESS you come back and say this is on the standard ~20cm FFC cable shipped with Pi cameras in a normal environment (ie not adjacent to a welding rig). Even then I'd suspect a hardware issue with one of the devices as it is not a systemic issue.
Hello, 6by9. I use the standard ~20cm FFC cable shipped with Pi cameras but there may indeed be disturbances in the environment.
That concerns me slightly, but it's still more likely to be a bad Pi or camera than anything else.
If there are obvious sources of interference then remove them. Otherwise check if this is repeatable across hardware. You said you've tried both a v1 and v2 camera, so swapping the Pi (and FFC) would be the obvious next steps.
qhjiang wrote:
1. Why does the exchange of G/B or R/G always cause pinky-purple stripes? In my understanding, the result of this exchange is related to the relative relationship between the original R/B value and G value.
This problem has been bothering me for a long time. Could you please give me some advice? Thank you very much.
The channels are not equally sensitive - that's what white balance compensates for (within reason).
Green is left at x1.0, and red and blue are scaled. Running an IMX477 with "raspistill -set -t 0" prints out the AWB gains as around x2.8 on red, and x1.7 on blue, but obviously it varies based on the scene.

Drop a line from the incoming image, and suddenly the sensor's red and blue pixels are being multiplied x1.0 from the green channel processing, and the sensor's green pixels (which is most sensitive to start with) gets multiplied by 3.0 and 1.5. An image dominated by red and blue will look pinky/magenta, closer to red/purple due to the increased gains on that channel.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

qhjiang
Posts: 10
Joined: Thu May 06, 2021 12:17 pm

Re: Pinky purple stripes and a discontinuity in the image.

Thu May 13, 2021 1:35 am

Drop a line from the incoming image, and suddenly the sensor's red and blue pixels are being multiplied x1.0 from the green channel processing, and the sensor's green pixels (which is most sensitive to start with) gets multiplied by 3.0 and 1.5. An image dominated by red and blue will look pinky/magenta, closer to red/purple due to the increased gains on that channel.
Thank you very much, 6by9. It makes sense. But the whole process above does not cause the value of the green channel to be zero. When I read the RGB value of the purple lines, the green channel value is always zero. This is very strange.

Return to “Camera board”