Skip to content

Commit

Permalink
Improvements for s.d. return and fixed a uint16 limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
wandell committed Jul 24, 2020
1 parent 6b64518 commit 150821d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 29 deletions.
59 changes: 38 additions & 21 deletions scene/macbeth/macbethPatchData.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
function mRGB = macbethPatchData(obj,mLocs,delta,fullData,dataType)
function [mRGB,stdRGB] = macbethPatchData(obj,mLocs,delta,fullData,dataType)
% Return a cell array with the linear RGB values from an ip or sensor
%
% mRGB = macbethPatchData(obj,mLocs,delta)
% [mRGB, stdRGB] = macbethPatchData(obj,mLocs,delta)
%
% Returns the linear RGB values from the sensor or processor window
% Input:
% obj: A scene, oi, sensor or ip struct
% mLocs: Mean locations of the MCC patches
% delta: Size of the rect for each patch
% fullData: Return all the RGB data from each patch (1) or the mean (0)
% dataType: Depends on the object type
%
% Example:
% Add example
% Output
% mRGB: Either a cell array with data from each of the 24 patches or a
% matrix (24 x 3) with the mean RGB values from each patch
% stdRGB: When mean is returned this matrix contains the corresponding
% standard deviatons
%
% See Also: macbethSelect, vcimageMCCXYZ, macbethColorError
% See Also:
% macbethSelect, vcimageMCCXYZ, vcGetROIData, macbethColorError
%
% Copyright ImagEval Consultants, LLC, 2011.

% Examples:
%{
% Add example
%}



%% Parse inputs

Expand All @@ -20,25 +35,27 @@
if ieNotDefined('fullData'),fullData = 0; end % Mean, not all the points
if ieNotDefined('delta'), dataType = 'result'; end % Default for vcimage

%%
if fullData % Every value in the patch
%% Get the object using the mLocs and dataType spec

% mLocs() is a 2 x 24 matrix with the center of each patch as
% the (row,col)'
if fullData % The values from every location in each of the 24 patches
mRGB = cell(1,24);
for ii = 1:24
% mLocs(:,mPatch) is a column vector with (row,col)' for the
% mPatch.
theseLocs = macbethROIs(mLocs(:,ii),delta);
for ii = 1:24
theseLocs = macbethROIs(mLocs(:,ii),delta); % List locs for this patch
mRGB{ii} = vcGetROIData(obj,theseLocs,dataType);
end
else % Mean values from each patch

mRGB = zeros(24,3); % This should be 24 x nSensors, not 24 x 3
stdRGB = zeros(24,3); % This should be 24 x nSensors

for ii = 1:24
% mLocs(:,mPatch) is a column vector with (row,col)' for the
% mPatch.
% This code doesn't work properly for the case of an image sensor.
% It needs to protect against the NaNs returned in that case. It
% works OK for the vcimage. Fix this some day.
if strcmp(obj.type,'sensor'), error('Use fullData = 1'); end
theseLocs = macbethROIs(mLocs(:,ii),delta);
mRGB(ii,:) = mean(vcGetROIData(obj,theseLocs,dataType));
theseLocs = macbethROIs(mLocs(:,ii),delta); % List locs for this patch
% The sensor case will have NaNs
theseData = vcGetROIData(obj,theseLocs,dataType);
mRGB(ii,:) = nanmean(theseData);
stdRGB(ii,:) = nanstd(theseData);
end
end

Expand Down
14 changes: 8 additions & 6 deletions scene/macbeth/macbethSelect.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function [mRGB, mLocs, pSize, cornerPoints] = ...
function [mRGB, mLocs, pSize, cornerPoints, mRGBstd] = ...
macbethSelect(obj,showSelection,fullData,cornerPoints)
%Identify Macbeth color checker patch positions from window image
%
% Synopsis
% [mRGB mLocs, pSize, cornerPoints] =
% [mRGB mLocs, pSize, cornerPoints, mRGBstd] =
% macbethSelect(obj,showSelection,fullData,cornerPoints)
%
% Brief Description
Expand Down Expand Up @@ -44,6 +44,7 @@
% sample positions with a (row,col) coordinate.
% pSize: The size of the square region in the center of the patch
% cornerPoints: Corner points of the selected MCC
% mRGBstd: Standard deviation when the mean values are requested
%
% In ISET the ordering of the Macbeth patches is:
%
Expand Down Expand Up @@ -130,7 +131,7 @@
handles = ieSessionGet('vcimage handles');
dataType = 'result';
obj = ipSet(obj,'mcc Rect Handles',[]);
vcReplaceObject(obj);
vcReplaceObject(obj); ipWindow;
if ieNotDefined('cornerPoints')
cornerPoints = ipGet(obj,'mcc corner points');
end
Expand All @@ -139,15 +140,16 @@
handles = ieSessionGet('sensor Window Handles');
dataType = 'dvorvolts';
obj = sensorSet(obj,'mcc Rect Handles',[]);
vcReplaceObject(obj);
% Make sure these data are in the sensor in the window
vcReplaceObject(obj); sensorWindow;
if ieNotDefined('cornerPoints')
cornerPoints = sensorGet(obj,'mcc corner points');
end
case {'scene'}
handles = ieSessionGet('scene Window Handles');
dataType = 'photons';
obj = sceneSet(obj,'mcc Rect Handles',[]);
vcReplaceObject(obj);
vcReplaceObject(obj); sceneWindow;
if ieNotDefined('cornerPoints')
cornerPoints = sensorGet(obj,'mcc corner points');
end
Expand Down Expand Up @@ -227,7 +229,7 @@
% Get the mean RGB data or the full data from the patches in a cell array
% The processor window is assumed to store linear RGB values, not gamma
% corrected.
mRGB = macbethPatchData(obj,mLocs,delta,fullData,dataType);
[mRGB,mRGBstd] = macbethPatchData(obj,mLocs,delta,fullData,dataType);

% Plot the rectangles.
if showSelection, macbethDrawRects(obj); end
Expand Down
6 changes: 4 additions & 2 deletions sensor/gui/sensorData2Image.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@
end

% Scale the displayed image intensity to the range between 0 and
% the voltage swing. RGB images are supposed to run from 0,1
img = img/mxImage;
% the voltage swing. RGB images are supposed to run from 0,1.
%
% If the dv data are ints, we need to cast the max as a double
img = img/double(mxImage);
img = ieClip(img,0,1).^gam;

elseif nSensors == 1
Expand Down

0 comments on commit 150821d

Please sign in to comment.