-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplotColorHistogram.m
More file actions
42 lines (36 loc) · 889 Bytes
/
plotColorHistogram.m
File metadata and controls
42 lines (36 loc) · 889 Bytes
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
function plotColorHistogram(hist, figureHandle, subplotHandle)
%UNTITLED Summary of this function goes here
% hist is an N x N x N matrix
% N =< 256
N = size(hist,1);
multiple = 256/N;
scale = 100;
% positive values as normal colors
linearIndices = find(hist > 0);
[x, y, z] = ind2sub([N, N, N], linearIndices);
x = multiple*x;
y = multiple*y;
z = multiple*z;
figure(figureHandle);
subplotHandle;
warning('off','all')
scatter3(x,y,z,scale*hist(linearIndices),[x, y, z]/256, 'filled');
hold on;
% negative values as inverse
linearIndices = find(hist < 0);
[x, y, z] = ind2sub([N, N, N], linearIndices);
x = multiple*x;
y = multiple*y;
z = multiple*z;
figure(figureHandle);
subplotHandle;
warning('off','all')
scatter3(x,y,z,scale*-hist(linearIndices),1-[x, y, z]/256, 'filled');
hold off;
xlabel('R');
ylabel('G');
zlabel('B');
xlim([0, 256]);
ylim([0, 256]);
zlim([0, 256]);
end