|
3 | 3 | % |
4 | 4 | % JHIST = jointHistogram(I1, I2); |
5 | 5 | % 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. |
7 | 7 | % |
8 | 8 | % 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; |
10 | 13 | % |
11 | 14 | % See also |
12 | 15 | % histogram |
13 | 16 | % |
14 | 17 |
|
15 | 18 | % ------ |
16 | 19 | % Author: David Legland |
17 | | -% e-mail: david.legland@inra.fr |
| 20 | +% e-mail: david.legland@inrae.fr |
18 | 21 | % Created: 2019-11-25, using Matlab 8.6.0.267246 (R2015b) |
19 | 22 | % Copyright 2019 INRA - Cepia Software Platform. |
20 | 23 |
|
|
99 | 102 | res(v1, v2) = res(v1, v2)+1; |
100 | 103 | end |
101 | 104 | else |
| 105 | + % More generic case: iterate over all pixels, find indices of first |
| 106 | + % bins greater than each value |
102 | 107 | for i = 1:length(inds) |
103 | 108 | % get each value, and convert to index |
104 | 109 | v1 = find(obj1.Data(inds(i))>=vals1, 1, 'last'); |
|
109 | 114 | end |
110 | 115 | end |
111 | 116 |
|
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