Skip to content

Commit e595556

Browse files
committed
jointHistogram.m: enhance meta data of resulting image
1 parent 4c1bfc9 commit e595556

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/@Image/jointHistogram.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
%
44
% JHIST = jointHistogram(I1, I2);
55
% I1 and I2 are two images with the same size, JHIST is a 256-by-256
6-
% array containing number of pixels for each combination of values.
6+
% image containing number of pixels for each combination of values.
77
%
88
% Example
9-
% jointHistogram
9+
% % Compute joint histogram on two channels of a color image
10+
% img = Image.read('peppers.png');
11+
% histoRG = jointHistogram(channel(img, 1), channel(img, 2));
12+
% figure; show(log(histoRG+1)); colormap jet;
1013
%
1114
% See also
1215
% histogram
1316
%
1417

1518
% ------
1619
% Author: David Legland
17-
% e-mail: david.legland@inra.fr
20+
% e-mail: david.legland@inrae.fr
1821
% Created: 2019-11-25, using Matlab 8.6.0.267246 (R2015b)
1922
% Copyright 2019 INRA - Cepia Software Platform.
2023

@@ -99,6 +102,8 @@
99102
res(v1, v2) = res(v1, v2)+1;
100103
end
101104
else
105+
% More generic case: iterate over all pixels, find indices of first
106+
% bins greater than each value
102107
for i = 1:length(inds)
103108
% get each value, and convert to index
104109
v1 = find(obj1.Data(inds(i))>=vals1, 1, 'last');
@@ -109,4 +114,7 @@
109114
end
110115
end
111116

112-
res = Image('Data', res);
117+
% create new image
118+
res = Image('Data', res, ...
119+
'Name', 'JointHistogram', ...
120+
'AxisNames', {obj1.Name, obj2.Name});

0 commit comments

Comments
 (0)