-
Notifications
You must be signed in to change notification settings - Fork 0
/
channelPlot.m
42 lines (36 loc) · 1.21 KB
/
channelPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function varargout = channelPlot(rgb, varargin)
names = {'rgb', 'hsv', 'lab', 'sqrt(xyz)', 'ntsc', 'ycbcr'};
imData{1} = rgb;
imData{2} = rgb2hsv(rgb);
imData{3} = rgb2lab(rgb);
imData{4} = sqrt(rgb2xyz(rgb));
imData{5} = rgb2ntsc(rgb);
imData{6} = rgb2ycbcr(rgb);
if nargin == 2 && ~ischar(varargin{1}) && all(class(varargin{1}) == 'function_handle')
imData = cellfun(varargin{1}, imData, 'UniformOutput', false);
names = {'f(rgb)', 'f(hsv)', 'f(lab)', 'f(sqrt(xyz))', 'f(ntsc)', 'f(ycbcr)'};
elseif nargin > 1 && strcmp(varargin{end}, 'oneplot')
figure;
runsum = 1;
for ii = length(imData):-1:1
data = imData{ii};
ch = size(data, 3);
for jj = 1:ch
subplot(length(imData), 3, runsum)
imsc(data(:, :, jj));
title(sprintf('%s(%d)', names{ii}, jj))
runsum = runsum + 1;
end
end
return
end
for ii = length(imData):-1:1
data = imData{ii};
ch = size(data, 3);
for jj = 1:ch
figure;
imsc(data(:, :, jj));
title(sprintf('%s(%d)', names{ii}, jj))
end
end
end