{"action":"created","issue":{"url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation/issues/1","repository_url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation","labels_url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation/issues/1/comments","events_url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation/issues/1/events","html_url":"https://github.com/cpixip/simple_picam_lens_compensation/issues/1","id":376936483,"node_id":"MDU6SXNzdWUzNzY5MzY0ODM=","number":1,"title":"Sensor mode issue","user":{"login":"zbarna","id":38557145,"node_id":"MDQ6VXNlcjM4NTU3MTQ1","avatar_url":"https://avatars1.githubusercontent.com/u/38557145?v=4","gravatar_id":"","url":"https://api.github.com/users/zbarna","html_url":"https://github.com/zbarna","followers_url":"https://api.github.com/users/zbarna/followers","following_url":"https://api.github.com/users/zbarna/following{/other_user}","gists_url":"https://api.github.com/users/zbarna/gists{/gist_id}","starred_url":"https://api.github.com/users/zbarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbarna/subscriptions","organizations_url":"https://api.github.com/users/zbarna/orgs","repos_url":"https://api.github.com/users/zbarna/repos","events_url":"https://api.github.com/users/zbarna/events{/privacy}","received_events_url":"https://api.github.com/users/zbarna/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-11-02T19:17:14Z","updated_at":"2018-11-30T20:50:42Z","closed_at":null,"author_association":"NONE","body":"Hi @cpixip!\r\n\r\nRegarding our conversation here: https://github.com/waveform80/picamera/pull/470, I write my remarks about your code.\r\n\r\nSo the code is working well, and I made some test with different camera configs (I took picture about a yellow painted plastic item):\r\nsensor_mode = 1, awb_mode = off, awb_gain=(1.5, 1.0) (this is perfect!)\r\n![2018-11-02_190228](https://user-images.githubusercontent.com/38557145/47935000-4b749080-ded9-11e8-9ba8-ac23bb4fc91e.jpg)\r\n\r\nsensor_mode = 2, awb_mode = off, awb_gain=(1.5, 1.0) (at the sides it's a little bit whiter)\r\n![2018-11-02_190254](https://user-images.githubusercontent.com/38557145/47934882-ede04400-ded8-11e8-9f5c-e812016660e9.jpg)\r\n\r\nsensor_mode = 2, awb_mode = on (at the sides it's a little bit whiter)\r\n![2018-11-02_190202](https://user-images.githubusercontent.com/38557145/47935219-f9803a80-ded9-11e8-8f63-86aac3a80a67.jpg)\r\n\r\nHere you can see the meaning of the sensor modes: https://picamera.readthedocs.io/en/release-1.13/fov.html#sensor-modes\r\n\r\nI would like to use the sensor_mode = 2, because in that mode I can see the full view of the camera.\r\n\r\nI think your code calibrate the sensor_mode = 1 picture. I tried to modify the camera config in the script but didn't help. What do you think? Have you got this issue as well?\r\n\r\nThe other thing: After a few test, I realized that if the awb is on, the lens_shading table is not working well. What's your opinion?\r\n\r\nThanks!\r\nBest Regards,\r\nzbarna\r\n"},"comment":{"url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation/issues/comments/443335392","html_url":"https://github.com/cpixip/simple_picam_lens_compensation/issues/1#issuecomment-443335392","issue_url":"https://api.github.com/repos/cpixip/simple_picam_lens_compensation/issues/1","id":443335392,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzMzNTM5Mg==","user":{"login":"cpixip","id":43588739,"node_id":"MDQ6VXNlcjQzNTg4NzM5","avatar_url":"https://avatars2.githubusercontent.com/u/43588739?v=4","gravatar_id":"","url":"https://api.github.com/users/cpixip","html_url":"https://github.com/cpixip","followers_url":"https://api.github.com/users/cpixip/followers","following_url":"https://api.github.com/users/cpixip/following{/other_user}","gists_url":"https://api.github.com/users/cpixip/gists{/gist_id}","starred_url":"https://api.github.com/users/cpixip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpixip/subscriptions","organizations_url":"https://api.github.com/users/cpixip/orgs","repos_url":"https://api.github.com/users/cpixip/repos","events_url":"https://api.github.com/users/cpixip/events{/privacy}","received_events_url":"https://api.github.com/users/cpixip/received_events","type":"User","site_admin":false},"created_at":"2018-11-30T20:50:42Z","updated_at":"2018-11-30T20:50:42Z","author_association":"OWNER","body":"Hi @zbarna,\r\n\r\nthe integrating sphere you asked about is designed to be used in a Super 8 film scanner. It is very much still in the design phase. Furthermore, it only has a small window sufficient for the film frame to be used, so it is not something that I would recommend reprinting. You can't use it in your setup. Here's a picture to give you some idea:\r\n\r\n![20180709_200910_s](https://user-images.githubusercontent.com/43588739/49311817-85d64b00-f4e2-11e8-8382-e13c2e888d01.jpg)\r\n\r\n\r\nIt's the glowing thing on the right. Well, printing takes a lot of time and material.  It requires further a lot of supporting electronics and software to be usable. So I do not think this will help you too much, at least in the current design phase. Once the design is settled, I will probably put the design on Thingiverse or so.\r\n\r\nIt is great that you did the experiments with the phone as light source. In this way, you could adjust all 4 raw channels to a similar mean value. Interestingly, you than end up with a lens compensation table\r\n\r\n![p2](https://user-images.githubusercontent.com/43588739/49311969-e2d20100-f4e2-11e8-9785-2a63c00c9060.JPG)\r\n\r\nwhich is very similar to the compensation tables I get with my setup. And totally different from the ones you got with either your cold or warm light source!\r\n\r\nNow, note that this compensation table only displays rather coarsely digitized regions. The values in the table range only between 32 and 40. The reason is that the coding of the lens shading table is poorly chosen (which I already remarked in a discussion at the Raspberry Pi forum). Because of this, you are going to end up with tiny little color variations in your final image. Look at your image which you have taken with this lens compensation table\r\n\r\n![p1](https://user-images.githubusercontent.com/43588739/49312108-62f86680-f4e3-11e8-912b-dc4362d33501.JPG)\r\n\r\nI white-balanced your image and increased the intensity range to the maximum. Note that there are patches with varying color across this image. These are color variation caused by the poorly chosen coding in the implementation of the Raspberry image pipeline.\r\n\r\nSince you supplied me with the raw images, I can show you here what your lens compensation \r\ntable would look like if it was coded as float: \r\n\r\n![p3](https://user-images.githubusercontent.com/43588739/49312233-cc787500-f4e3-11e8-8302-18847161d5f0.JPG)\r\n\r\na rather dramatic difference! Of course, the slightly colored patches are gone if I am using \r\nthe \"float\" lens compensation table.\r\n\r\nOne remark here: you could increase the scaler (per default at 32) to a higher value. This would\r\nincrease the digital precision of the lens compensation table. It would also lead to an increased\r\nsensitivity of the camera and an increase in the noise level. And it could saturate the \r\nprocessing during later stages in the camera pipeline. However, from my experience, scalers of \r\n48 or 64 are fine. They will increase the digital precision of the lens compensation table \r\nto a point where the aforementioned color patches are no longer noticeable.\r\n\r\nNow, back to the main issue. Thanks again for sharing your raw images with the phone as light\r\nsource. If you look at one of your \"blue\" images, \r\n\r\n![p4](https://user-images.githubusercontent.com/43588739/49312273-f6ca3280-f4e3-11e8-8d60-70c2aea8fc32.JPG)\r\n\r\nyou see exactly the same pattern with your optical setup as the one I found with my lens (the Green1 and Green2 channels are swapped in the image above, as compared to my setup posted earlier). \r\n\r\nYou can see in both images that the color spill from the blue channel creates a nice pattern. And, importantly, the pattern is identical in your and my setup (save of the swap of the green channels, as noted).\r\n\r\nWell, this pattern displays the crosstalk I was talking about. The spatially varying spill from the blue color channel is caused by the mismatch between microlens/Bayer pattern and the non-matching lens. If you think about it geometrically, you would expect in one  of the green channels a spill which is strongest at the top and bottom of the frame (top-right) and in the other green channel a spill which strongest at the left and right sides of the frame (bottom-right). Also, the spill from the blue channel should be roughly circular symmetric in the red channel (top-left) and reduce the values in the blue channel similar like \"normal\"  vignetting (bottom-right). As you can see, this is exactly the case. And again, this color spill pattern shows up with your setup as well as with my lens.\r\n\r\nThe spill will manifest itself in several ways which will make it difficult to obtain high-quality color images. First, the colors recorded towards the edges of the frame will shift, compared to the center. The white balance algorithm of the Raspberry pipeline will tend to enhance this color shift.  Also, there will be a desaturation of color values toward the edges - something I have seen in many images posted on the web where the standard lens of the v1- or v2-camera was removed. As you know, the effect is much more pronounced with the v2-camera, due to the larger CRA-compensation used. This can also been seen in many images available on the net. Furthermore, a light source which adds uneven power in the color channels will worsen the situation. As your light measurements indicate, this is exactly the case with your cold/warm light source. \r\n\r\nSo, I don't know... - the thing is: we can do nothing to compensate this color spill effect within the current Raspi image pipeline. At this point in time, I can only see a few approaches which might counteract the issue:\r\n\r\n1) one could only use a subframe of the full image, where the color spill is not too large for image acquisition. I think this is doable, but the resolution will probably be limited to 800x600 at most.\r\n\r\n2) one could forget about the Raspberry Pi image processing pipeline, capture the raw images and do\r\nall the processing separately. Advantage is that you can use more sophisticated algorithms. The primary  disadvantage is that your frame rate drops to rather low values of about a single frame per second. Not reasonable for most applications (certainly not applicable for mine). And of course, you need a lot of knowledge to implement appropriate algorithms. \r\n\r\n3) one could modify the optical pathway in such a way that one can work with the standard lens attached\r\nto the camera. Advantage would be that the camera is used as it was designed to be used. One could even upgrade to the higher resolution v2-camera in this case. Actually, some people have realized a Super-8 scanner in that way, simply by prefixing a sufficiently strong lens in front of the normal Raspi cam. I tried this approach about a year ago, but I could not obtain a lens with a sufficient magnification and good enough optical properties to map the Super-8 frame to the full sensor. In your case, which is, I assume microscopic work, you could simply try to have the camera look through a normal eye piece. Some people had quite some success with mobile phones attached to a microscope in that way, and the Raspi cams are mobile phone camera at heart.\r\n\r\nWell, that's it for the moment. In case I come up with another solution, I will let you know. At this point in time, I have no other ideas. Actually, I am currently thinking of going go back to an option I was considering before, namely using a more expensive machine vision camera for my project. \r\n\r\nBest, cpixip\r\n"}}
{"actor":{"display_login":"cpixip"}}