Skip to content

Commit

Permalink
ipPlot fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wandell committed Jun 19, 2020
1 parent 39b2b86 commit 10e52a3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
10 changes: 5 additions & 5 deletions color/chromaticityPlot.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function g = chromaticityPlot(pts,background,nPix,newFig)
% Draw points superimposed on an xy chromaticity diagram
%
% g = chromaticityPlot(pts,[background='gray'],[nPix=256])
% g = chromaticityPlot(pts,[background='gray'],[nPix=256], [newFig])
%
% The general surrounding background can be gray (by default), white or
% black.
Expand Down Expand Up @@ -35,7 +35,7 @@
if ieNotDefined('pts'), pts = []; end
if ieNotDefined('background'), background = 'gray'; end
if ieNotDefined('nPix'), nPix = 256; end
if ieNotDefined('newFig'), newFig = 1; end
if ieNotDefined('newFig'), newFig = true; end
g = [];

%% Create a mesh grid of points filled with xy values
Expand Down Expand Up @@ -71,13 +71,13 @@
switch background
case 'white'
backXYZ = backXYZ*Y_val;
if newFig, g = vcNewGraphWin([],[],'Color',[1 1 1]); end
if newFig, g = ieNewGraphWin([],[],'Color',[1 1 1]); end
case 'black'
backXYZ = backXYZ*0;
if newFig, g = vcNewGraphWin([],[],'Color',[0 0 0]); end
if newFig, g = ieNewGraphWin([],[],'Color',[0 0 0]); end
case 'gray'
backXYZ = backXYZ*Y_val/2;
if newFig, g = vcNewGraphWin([],[],'Color',[0.7 0.7 0.7]); end
if newFig, g = ieNewGraphWin([],[],'Color',[0.7 0.7 0.7]); end
otherwise
error('Unknown background %s\n',background);
end
Expand Down
29 changes: 15 additions & 14 deletions utility/plots/plotDisplayColor.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,30 @@ function plotDisplayColor(ip,dataType)
% See also: plotDisplayGamut
%
% Examples:
% vci = vcGetObject('vci');
% plotDisplayColor(vci,'xy'); userData = get(gcf,'UserData');
% ip = ieGetObject('ip');
% plotDisplayColor(ip,'xy'); userData = get(gcf,'UserData');
%
% plotDisplayColor([],'luminance')
% plotDisplayColor([],'cielab')
%
% Copyright ImagEval Consultants, LLC, 2005.

% TODO: Restructure using a new routine, plotIP
%

%% Variables
if ieNotDefined('vci'); ip = vcGetObject('vcimage'); end
if ieNotDefined('ip'); ip = vcGetObject('ip'); end
if ieNotDefined('dataType'), dataType = 'rgbhistogram'; end

%% Select the RGB data from the ROI
handles = ieSessionGet('vcimagehandle');

% Get the data
ieInWindowMessage('Select image region of interest.',handles,[]);
roiLocs = vcROISelect(ip);
roiLocs = ieROISelect(ip);
RGB = vcGetROIData(ip,roiLocs,'result');
ieInWindowMessage('',handles,[]);

%% Plot the data

figNum = vcNewGraphWin;
figNum = ieNewGraphWin;

switch lower(dataType)
case {'rgb','rgbhistogram'}
Expand Down Expand Up @@ -88,8 +85,12 @@ function plotDisplayColor(ip,dataType)
dataXYZ = imageRGB2XYZ(ip,RGB);
xy = chromaticity(dataXYZ);

plotSpectrumLocus(figNum); hold on;
plot(xy(:,1),xy(:,2),'o');
% Gray background, res of 256, do not start a new figure
chromaticityPlot(xy,'gray',256,false);

% plotSpectrumLocus(figNum); hold on;
hold on
plot(xy(:,1),xy(:,2),'ko');
grid on;

title('CIE (1931) chromaticities');
Expand All @@ -98,7 +99,7 @@ function plotDisplayColor(ip,dataType)

meanXYZ = mean(dataXYZ);

txt = sprintf('X = %.02f\nY = %.02f\nZ = %.02f',meanXYZ(1),meanXYZ(2),meanXYZ(3));
txt = sprintf(' Mean XYZ \nX = %.02f\nY = %.02f\nZ = %.02f',meanXYZ(1),meanXYZ(2),meanXYZ(3));
plotTextString(txt,'ur');

udata.xy = xy; udata.XYZ = dataXYZ;
Expand All @@ -108,7 +109,7 @@ function plotDisplayColor(ip,dataType)
dataXYZ = imageRGB2XYZ(ip,RGB);
luminance = dataXYZ(:,2);

hist(luminance(:)); grid on;
histogram(luminance(:)); grid on;
xlabel('Luminance (cd/m^2)'); ylabel('Count'); title('Luminance (CIE 1931 Y)');
set(gca,'xlim',[max(0,0.*min(luminance(:))), max(luminance(:))*1.1]);
mnL = mean(luminance);
Expand All @@ -124,7 +125,7 @@ function plotDisplayColor(ip,dataType)
% Needs updating
dataXYZ = ipGet(ip,'roi xyz',roiLocs);
whitepnt = ipGet(ip,'data or Display WhitePoint');
dataLAB = ieXYZ2LAB(dataXYZ,whitepnt);
dataLAB = ieXYZ2LAB(double(dataXYZ),double(whitepnt));
plot3(dataLAB(:,2), dataLAB(:,3),dataLAB(:,1), 'o');
set(gca,'xlim',[-50 50],'ylim',[-50 50],'zlim',[0,100]);
grid on; axis square
Expand Down Expand Up @@ -160,4 +161,4 @@ function plotDisplayColor(ip,dataType)
set(figNum,'Userdata',udata);
hold off

return;
end
12 changes: 7 additions & 5 deletions utility/plots/plotSpectrumLocus.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
%
% Copyright Imageval 2003

if ieNotDefined('fig'), vcNewGraphWin;
else figure(fig);
if ieNotDefined('fig'), ieNewGraphWin;
else, figure(fig);
end

wave = 370:730;
Expand All @@ -24,13 +24,15 @@
spectrumLocus = chromaticity(XYZ);

% These are the (x,y) points of the spectral lines
p = plot(spectrumLocus(:,1),spectrumLocus(:,2),'-');
p = plot(spectrumLocus(:,1),spectrumLocus(:,2),'k--');
hold on;

% Add a line to close up the outer rim of the spectrum locus curve
l = line([spectrumLocus(1,1),spectrumLocus(end,1)],...
[spectrumLocus(1,2),spectrumLocus(end,2)]);
[spectrumLocus(1,2),spectrumLocus(end,2)], ...
'Color',[0 0 0],'LineStyle','--');

hold on;
axis equal; grid on

return;
end

0 comments on commit 10e52a3

Please sign in to comment.