diff --git a/gui/chart/chartCornerpoints.m b/gui/chart/chartCornerpoints.m index 2f097907..bd6dac30 100644 --- a/gui/chart/chartCornerpoints.m +++ b/gui/chart/chartCornerpoints.m @@ -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,... @@ -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' @@ -109,7 +112,7 @@ ipWindow otherwise - error('Unknown object type'); + error('Unknown object type %s\n',obj.type); end diff --git a/gui/ieRefreshWindow.m b/gui/ieRefreshWindow.m index a4c12991..35c4590c 100644 --- a/gui/ieRefreshWindow.m +++ b/gui/ieRefreshWindow.m @@ -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. @@ -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; \ No newline at end of file +end diff --git a/imgproc/ipMCCXYZ.m b/imgproc/ipMCCXYZ.m new file mode 100644 index 00000000..3b73b81d --- /dev/null +++ b/imgproc/ipMCCXYZ.m @@ -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 diff --git a/imgproc/vcimageMCCXYZ.m b/imgproc/vcimageMCCXYZ.m index 4d34b14f..fa6f63b0 100644 --- a/imgproc/vcimageMCCXYZ.m +++ b/imgproc/vcimageMCCXYZ.m @@ -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) % @@ -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 @@ -97,3 +102,4 @@ end +%} diff --git a/scene/macbeth/macbethColorError.m b/scene/macbeth/macbethColorError.m index cabf0402..588875d8 100644 --- a/scene/macbeth/macbethColorError.m +++ b/scene/macbeth/macbethColorError.m @@ -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. @@ -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 diff --git a/scene/macbeth/macbethPatchData.m b/scene/macbeth/macbethPatchData.m index 92c40863..ffdcda7a 100644 --- a/scene/macbeth/macbethPatchData.m +++ b/scene/macbeth/macbethPatchData.m @@ -17,7 +17,7 @@ % standard deviatons % % See Also: -% macbethSelect, vcimageMCCXYZ, vcGetROIData, macbethColorError +% macbethSelect, ipMCCXYZ, vcGetROIData, macbethColorError % % Examples: @@ -25,8 +25,6 @@ % Add example %} - - %% Parse inputs if ieNotDefined('obj'), error('vcimage or sensor required'); end