Skip to content

Commit

Permalink
Updated for G work. Nothing special.
Browse files Browse the repository at this point in the history
  • Loading branch information
wandell committed Jul 25, 2020
1 parent 150821d commit 49c4f18
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 22 deletions.
9 changes: 6 additions & 3 deletions gui/chart/chartCornerpoints.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
% routines, without the specialization for MCC. This will require some
% fixing of the sceneSet,oiSet, ... and so forth.

if ieNotDefined('obj'), error('Sensor or IP object required.'); end
if ieNotDefined('obj'), error('Scene,oi,sensor or ip object required.'); end
if ieNotDefined('wholeChart'), wholeChart = false; end

ieReplaceObject(obj);
ieRefreshWindow(obj.type);

if ~wholeChart
% Get the user to select corner points in the window.
cornerPoints = vcPointSelect(obj,4,...
Expand All @@ -69,7 +72,7 @@
cornerPoints = [1,y; x,y; x,1; 1,1];
end
obj = sceneSet(obj,'chart corners',cornerPoints);
vcReplaceObject(obj);
ieReplaceObject(obj);
sceneWindow;

case 'opticalimage'
Expand Down Expand Up @@ -109,7 +112,7 @@
ipWindow

otherwise
error('Unknown object type');
error('Unknown object type %s\n',obj.type);
end


Expand Down
33 changes: 21 additions & 12 deletions gui/ieRefreshWindow.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
function ieRefreshWindow(objType)
function hdl = ieRefreshWindow(objType)
%Refresh one of the four types of windows
%
% Synopsis
% ieRefreshWindow(objType)
%
% Input
% objType: A string defining the object type. If obj is an ISETCam
% struct, then this could be obj.type
%
% Output
% hdl: Handle to the window
%
%Purpose:
% Issue a refresh to one of the ISET windows. This routine is useful
% when you have changed the data and would like the window to update
% according to the new data.
%
% Example:
% vcReplaceObject(scene); ieRefreshWindow('scene');
% vcReplaceObject(oi); ieRefreshWindow('oi');
% vcReplaceObject(isa); ieRefreshWindow('isa');
% ieReplaceObject(scene); ieRefreshWindow('scene');
% vcReplaceObject(oi); ieRefreshWindow('opticalimage');
% vcReplaceObject(isa); ieRefreshWindow('sensor');
% vcReplaceObject(vcimage); ieRefreshWindow('vcimage');
% ieReplaceObject(obj); ieRefreshWindow(obj.type);
%
% Copyright ImagEval Consultants, LLC, 2003.

Expand All @@ -22,19 +31,19 @@ function ieRefreshWindow(objType)

switch lower(objType)
case {'scene'}
h = sceneWindow;
hdl = sceneWindow;

case {'opticalimage'}
h = oiWindow;
case {'opticalimage','oi'}
hdl = oiWindow;

case {'isa'}
h = sensorImageWindow;
case {'isa','sensor'}
hdl = sensorImageWindow;

case {'vcimage'}
h = ipWindow;
case {'vcimage','ip'}
hdl = ipWindow;

otherwise
error('Unknown object type');
end

return;
end
104 changes: 104 additions & 0 deletions imgproc/ipMCCXYZ.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
function [macbethXYZ, whiteXYZ, cornerPoints] = ipMCCXYZ(ip,cornerPoints,method)
%Estimate XYZ values of the MCC patches and the image white point from ip
%
% [macbethXYZ, whiteXYZ] = ipMCCXYZ(ip,pointLoc,method)
%
% We assume the ip has an image of the MCC in its output field
%
% ip: The virtual camera image structure
% pointLoc: Outer points of the MCC (usually selected by user)
% method: We either assume the display is an sRGB display (method =
% 'sRGB'), or we use the model display in the processor window
% (method = 'custom').
%
% macbethXYZ: 24 x 3
% whiteXYZ: 3 x 1, white point, which is macbethXYZ(4,:)
% pointLoc: Locations of the points in the image
%
% The MCC white patch the fourth row, first column.
%
% ieExamplesPrint('ipMCCXYZ');
%
% See Also:
% macbethColorError, macbethEvaluationGraphs
%

% Examples:
%{
ip = ieGetObject('ip');
[macbethXYZ, whiteXYZ] = ipMCCXYZ(ip);
ieNewGraphWin;
plot3(macbethXYZ(:,1),macbethXYZ(:,2),macbethXYZ(:,3),'o')
xy = chromaticity(macbethXYZ);
clf; plot(xy(:,1),xy(:,2),'o'); hold on; plotSpectrumLocus;
grid on; axis equal
macbethLAB = ieXYZ2LAB(macbethXYZ,whiteXYZ, 1);
clf; plot3(macbethLAB(:,1),macbethLAB(:,2), macbethLAB(:,3),'o');
set(gca,'xlim',[0 105]); grid on
%}


%% Check input variables
if ieNotDefined('ip'), ip = ieGetObject('ip'); end
if ieNotDefined('method'), method = 'sRGB'; end

% These pointLoc values are the coordinates of the corners of the MCC in
% the image.
% The extracted rgbData from the processor window are assumed to be linear
% values, not sRGB values or gamma corrected. They are the linear display
% primaries.
if ieNotDefined('cornerPoints')
% macbethSelect will prompt the user to identify corners.
[rgbData, mLocs, pSize, cornerPoints] = macbethSelect(ip);
if isempty(rgbData)
fprintf('%s: user canceled\n',mfilename);
macbethXYZ = []; whiteXYZ = []; cornerPoints = [];
return;
end
clear mLocs
clear pSize
else
% The user is not bothered
rgbData = macbethSelect(ip,0,0,cornerPoints);
end

%% Compute the

switch(lower(method))
case 'srgb'
% The display is treated as an sRGB.

% We read the data and convert them into sRGB values.
rgbLSRGB = lrgb2srgb(ieClip(rgbData,0,1));

% When convert the sRGB values into XYZ values for the RGB*L data.
% The format for sgb2xyz is (row,col,colorVector). We treat the
% MCC as one row, 24 columns, each with three entries.
rgbLSRGB = XW2RGBFormat(rgbLSRGB,4,6);
macbethXYZ = srgb2xyz(rgbLSRGB); % Y is in cd/m2
% vcNewGraphWin; image(xyz2srgb(macbethXYZ));

case 'custom'
% The routine imageRGB2XYZ accounts for the currently loaded
% display model, particularly the SPD of the display, to compute
% the MCC's XYZ values on the display.
rgbData = XW2RGBFormat(rgbData,4,6);
macbethXYZ = imageRGB2XYZ(ip,rgbData);
% vcNewGraphWin; image(xyz2srgb(macbethXYZ))

end


% Squeeze the singleton dimension
% Also, the data are now single format. For various CIELAB calculations
% they need to be double. So double() them here.
macbethXYZ = double(RGB2XWFormat(macbethXYZ));

% We pull out the white point to be a 3-vector from the more complex image
% structure.
whiteIndex = 4;
whiteXYZ = double(macbethXYZ(whiteIndex,:));


end
8 changes: 7 additions & 1 deletion imgproc/vcimageMCCXYZ.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function [macbethXYZ, whiteXYZ, cornerPoints] = vcimageMCCXYZ(vci,cornerPoints,method)
%Estimate XYZ values of the MCC patches and the image white point from vci
%DEPRECATED: Estimate XYZ values of the MCC patches and the image white point from vci
%
% USE ieMCCZYZ;
%
% [macbethXYZ, whiteXYZ] = vcimageMCCXYZ(vci,pointLoc,method)
%
Expand Down Expand Up @@ -34,6 +36,9 @@
% See Also: macbethColorError, macbethEvaluationGraphs
%

error('Use ieMCCXYZ');
%
%{
%% Check input variables
if ieNotDefined('vci'), vci = vcGetObject('vcimage'); end
if ieNotDefined('method'), method = 'sRGB'; end
Expand Down Expand Up @@ -97,3 +102,4 @@
end
%}
6 changes: 3 additions & 3 deletions scene/macbeth/macbethColorError.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
% to use the monitor model stored in the vci.
%
% Example:
% vci = vcGetObject('vcimage');
% [macbethXYZ, whiteXYZ] = vcimageMCCXYZ(vci);
% ip = vcGetObject('ip');
% [macbethXYZ, whiteXYZ] = ipMCCXYZ(vci);
%
% Copyright ImagEval Consultants, LLC, 2003.

Expand Down Expand Up @@ -75,7 +75,7 @@

% These are Processor window XYZ values using the monitor model. They are
% computed using a model monitor with peak luminance of Y = 1 cd/m2.
[macbethXYZ, whiteMacbethXYZ, cornerPoints] = vcimageMCCXYZ(vci,cornerPoints,method);
[macbethXYZ, whiteMacbethXYZ, cornerPoints] = ipMCCXYZ(vci,cornerPoints,method);
vci = ipSet(vci,'mcc corner points',cornerPoints);
vci = macbethDrawRects(vci); % Make sure we have ther rects
vci = macbethDrawRects(vci,'off'); % Now turn it all off
Expand Down
4 changes: 1 addition & 3 deletions scene/macbeth/macbethPatchData.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
% standard deviatons
%
% See Also:
% macbethSelect, vcimageMCCXYZ, vcGetROIData, macbethColorError
% macbethSelect, ipMCCXYZ, vcGetROIData, macbethColorError
%

% Examples:
%{
% Add example
%}



%% Parse inputs

if ieNotDefined('obj'), error('vcimage or sensor required'); end
Expand Down

0 comments on commit 49c4f18

Please sign in to comment.