Monochrome Debayer Option with Monochrome Camera

Do you have a patch that I could apply? What sort of code changes did you make?

Here’s the patch:

diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc
index a1f15787..acc9bf87 100644
--- a/rtengine/rawimagesource.cc
+++ b/rtengine/rawimagesource.cc
@@ -597,7 +597,7 @@ void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1,

 float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const float c_white[4], const float c_black[4], bool isMono, int colors)
 {
-    if (isMono || colors == 1) {
+    if (/*isMono || */colors == 1) {
         for (int c = 0; c < 4; c++) {
             scale_mul[c] = 65535.0 / (c_white[c] - c_black[c]);
         }

2 Likes

This is so cool! @dllewellyn love what you’re doing! Is it very complicated to have it done to a sensor? I take it the answer is a yes. I am wondering what the advantages are to making this modification. Off the top of my head, and without much experience in the field, I would assume that since normally in the bayer layout 4 sensor pixels (1R 2G 1B) produce the colours of 1 final jpg pixel, then taking the filters off would potentially produce an image where each pixel is a pixel …so 4x the camera’s original resolution?

Either way it’s awesome to see someone do this!

Advantages are

  • Around 3X greater efficiency at capturing photons
  • Up to 2X greater linear resolution … it varies from 1.05X to 2X depending on the effectiveness of the compared demosaicer … on average I’d put it at around 1.4X linear.
  • A lot less aliasing artefacts
2 Likes

Hi Stefan, with a monochorme camera, you gain spatial and contrast resolution while you lose color resolution. Most objects are mixes of RGB so while a monochrome camera does have higher resolution, it is rarely 4x. The microlenses that help concentrate light on the photodiode are also lost because they are on top of the CFA. Losing the microlenses and CFA change the frequency response of the sensor. In visible light, you gain about 2x more sensitivity. In UV light 6x, In IR light, net gain until 800nm and then net loss because the CFA becomes transparent above 800nm and you have lost the microlenses.

The biggest difference is that you see much more small contrast details.

5 Likes

thank you!

hello to everyone,
I’m a happy new client of Dan. I had my Sony A-6000 converted to BW and I get a kick out of it. However, I encounter the same grid problem “sometimes” when zooming in/enlarging some pictures, sometimes even when not enlarging.
See full frame Lady Liberty’s trees/pedestal here for instance.


This picture is my first try with RT after trying Darktable and Gimp (with Ufraw) This last one seems to work OK although the UX is hard to master.
I’m glad to have encountered RT since it looks like it gives a lot of control + you are pointing to a solution to the same problem I have.
ingo, can you explain how to apply your patch ? I am running RT packaged on Linux/Ubuntu (although not able to understand code, just daring enough to insert some in a given file). Let me know if you’d like some RAW files.

@pierpiotr that’s aliasing. Could you upload the raw file?

I can help you compile RT and apply the patch but I’d like to confirm whether it solves your issue first.

Use the “@” sign to get someone’s attention, e.g. @heckflosse

Hi @Morgan_Hardwood,
Here is the RAW file. DSC00179.ARW (23.6 MB)
Thanks for your help and for the tip “@” BTW

Can’t reproduce. Here’s a crop of your image as it shows in rt (I raised exposure a bit, because it’s quite dark)

@pierpiotr I noticed that you used RawTherapee 5.2. We couldn’t reproduce the problem using RawTherapee 5.4, so try upgrading.


DSC00179.jpg.out.pp3 (10.2 KB)

This is the same picture with with RT 5.4 It seems to solve the issue!
But I did not take the time to make it as good as you did @Morgan_Hardwood. Incidentaly, is any .pp3 file compatible across various PC / OS ? If yes, could you send me yours so that I would try it on the RAW file, please ?

Here is another pix after demosaicing

@pierpiotr the PP3 is compatible with all matching versions of RT regardless of operating system. I already attached it in my previous post. I used a development version of RT-5.4 but it should look fine in RT-5.4 stable.

Thank you @Morgan_Hardwood. I’ll try it on Sunday.

Hmm … there is still aliasing present … look AT 300% magnification at the top right corner during editing with RT with your pp3.
It comes from interaction of

  • pixelation present in raw values … This comes from RAW channel imbalance. In monochrome shots, normaly all channels (R,G1,B,G2) should give equal statistics … but here we have strong inbalance and the bad thing is that it is not consistend across the frame … it’s slight at the center … worse at the corners … and the worst is at the top right …
  • the slight rotation of 1.25°

With the use of sharpening and/or some arbitrary resampling ratios this can become visible at normal magnifications …

3 Likes

pier, if you have time available please shoot some flat frames* … this will give us reliable data regarding the channel imbalances … and there is strong possibility that applying flat field correction will correct all of them at the appropriate degree … maybe with a bit of tuning of the flat field algorithm …

*use a lens with no or negligible vignette, disable any vignette correction setting in camera, choose a flat featureless-non textured surface homogeneously lit, tune the focus point so that your surface is strongly out of focus, shoot it :wink:

1 Like

@heckflosse Ingo, I am searching for a way to separately scale G1 data because in the sample file I detected a mismatch around 4% …
The green equilibration has little or no effect here (I suppose it operates an averaging …)

The statistics are
R = 1.00 (it’s the most sensitive)
G2 = 1.00 (varies netween 0.99 - 1.01)
G1 = 0.96 (varies in 0.95 - 0.97)
B = 0.92 (0.94 at the left - 0.88 ar the right)
I’d like to normalize G1 to 1.00 then the WB will be more effective to normalize B …
The only way that comes to my mind is to manipulate the per channel camconst WhiteLevels … and I am not sure if this will work …

There should be a control that balances the greens. I don’t have RT on hand to make a screenshot ATM; see Green Equilibration section.

Hi @ilias_giarimis, here are 2 shots of white surfaces out fo focus, with a 55-210mm lens.
Thanks.
DSC00672.ARW (23.5 MB)
DSC00673.ARW (23.5 MB)

@pierpiotr please see Adding Support for New Raw Formats - RawPedia
The shots must be completely clipped.