Solved

Bayer Sampling for Image Simulation

  • 1 February 2023
  • 3 replies
  • 164 views

Is there a way to sample an image in a similar way as a Bayer sensor for the Image Simulation tool? Without making a custom Bayer slide surface for each image and imaging system?

For example: sampling an input image BMP as RGGB assuming bands 3+2+2+1, then providing the option of a raw or de-mosaiced color simulated image.

 

 

icon

Best answer by Leduse 11 February 2023, 01:54

View original

3 replies

Userlevel 7
Badge +3

+1 on this suggestion 

Userlevel 6
Badge +2

Hi @Leduse!

Thank you for sharing this idea. Ideally it would be nice to do this in the API but unfortunately the Image Simulation is not currently fully implemented in ZOS-API. 

However I think ZPL could work. I did a macro that makes a cross section of the result of the image simulation here:

Based on this, I am thinking that we could do a Bayer sensor. I have added a link to Wikipedia since I had to check (https://en.wikipedia.org/wiki/Bayer_filter). 

All the options are available via MODIFFYSETTINGS.

Let me know if you think that will help and happy to make an example if needed.

Hi Sandrine,

Thanks for the info! That sounds like a good approach.

I’ll read a bit more into ZPL. I think your macro uses most of the functions and syntax I would need to learn to make the Bayer code.

It will probably end up being very similar to this Matlab code I just wrote:

%import image
colorimg=imread('park.jpg');
dim=size(colorimg);
xpix=dim(2);
ypix=dim(1);

 

%These are placeholders for now, I would update them for color filter transmission + QE estimates

rimg=colorimg(:,:,1)*0.2126; 
gimg=colorimg(:,:,2)*0.7152;
bimg=colorimg(:,:,3)*0.0722;

%rggb
for n=1:ypix
    for m=1:xpix
        
        if mod(n,2)==1
            
                    %r
                    if mod(m,2)==1;
                    raw_mosaic(n,m)=rimg(n,m);

                    %g
                    else
                    raw_mosaic(n,m)=gimg(n,m);
                    end
        else
                    %g
                    if mod(m,2)==1;
                    raw_mosaic(n,m)=gimg(n,m);

                    %b
                    else
                    raw_mosaic(n,m)=bimg(n,m);
                    end
                    
        end
        
    end
end

subplot(1,2,1)
imagesc(colorimg), axis tight, axis equal, axis off, title('Unfiltered Color Image')
subplot(1,2,2)
imagesc(raw_mosaic), axis tight, axis equal, axis off, colormap gray, title('Bayer Filter Sim')

 

Reply