Simulate a sensor with stacked pixels, as in the Foveon sensor

Also, Langfelder hopes to use this design.

As a side-benefit, method here is also useful for those times we want to estimate sensor responses in the absence of demosaicking.

See also: ipCompute

Copyright ImagEval Consultants, LLC, 2012_

Contents

ieInit

Initialize a simple scene

% A few simple parameters
horizontalFOV = 8;
meanLuminance = 100;

scene = sceneCreate;
scene = sceneAdjustLuminance(scene,meanLuminance);
scene = sceneSet(scene,'hfov',horizontalFOV);
% ieAddObject(scene); sceneWindow;

Build the OI

oi = oiCreate;
oi = oiSet(oi,'optics fnumber',4);
oi = oiSet(oi,'optics focal length',3e-3);   % units are meters
oi = oiCompute(scene,oi);
% ieAddObject(oi); oiWindow;

Simulate a monochrome sensor

% Create a monochrome sensor.  We will reuse this structure to compute each
% of the complete color filters.
sensor = sensorCreate('monochrome');
sensor = sensorSetSizeToFOV(sensor,sceneGet(scene,'fov'),scene,oi);

% Make the sensor an XYZ type.  For Foveon or other simulation, but in
% different color filters.
wave   = sceneGet(scene,'wave');
sensor = sensorSet(sensor,'wave',wave);
filterFile = 'XYZQuanta';

wave     = sensorGet(sensor,'wave');
fSpectra = ieReadSpectra(filterFile,wave);   %load and interpolate filters
fSpectra = ieScale(fSpectra,1);
filterNames = {'rX','gY','bZ'};
% vcNewGraphWin; plot(wave,fSpectra)

Loop on the filters and calculate monochrome sensor planes

sensor = sensorCompute(sensor,oi);
ieAddObject(sensor); sensorWindow;

% For each of the filter transmissivities, compute the monoSensor photons.
sz = sensorGet(sensor,'size');
nChannels = size(fSpectra,2);
im = zeros(sz(1),sz(2),nChannels);
for kk=1:nChannels
    s = sensorSet(sensor,'filterspectra',fSpectra(:,kk));
    s = sensorSet(s,'Name',sprintf('Channel-%.0f',kk));
    s = sensorCompute(s,oi,0);
    ieAddObject(s); sensorWindow('scale',true);
    im(:,:,kk) = sensorGet(s,'volts');
end

Render the sensor data with the image processor (ipCompute)

% I place the im data into the volts field of an appropriate sensor. The
% sensor has the same properties as the monochrome sensor, but it has the
% proper color filters.
%
% When the sensor data are nxmx3, ipCompute treats this sensor like a
% triple-well and produce and output without demosaicking.

sensor = sensorCreate;
sensor = sensorSetSizeToFOV(sensor,sceneGet(scene,'fov'),scene,oi);

wave   = sceneGet(scene,'wave');
sensor = sensorSet(sensor,'wave',wave);
sensor = sensorSet(sensor,'filter spectra',fSpectra);
sensor = sensorSet(sensor,'volts',im);

ip = ipCreate;
ip = ipCompute(ip,sensor);
ip = ipSet(ip,'name','Triple Well');
ieAddObject(ip); ipWindow;
Interpolating display SPD for consistency with new wave.

See the equivalent calculation with a mosaic

sensor = sensorCompute(sensor,oi);
ip = ipCompute(ip,sensor);
ip = ipSet(ip,'name','Mosaicked');
ieAddObject(ip); ipWindow;