[Insight-users] Re: histogram : empty bins
Julien Jomier
jjomier at cs.unc.edu
Tue, 27 Jan 2004 11:02:12 -0500
Hi David,
I reproduced your problem.
During the creation of the histogram, the minimum and maximum values are =
set
automatically to the minimum and maximum values of the sample list.
Moreover, you are dealing with unsigned char pixel type and the minimum =
and
maximum pixel values of your image are not 0 and 255. The histogram
generator is creating bins of size (max-min)/NumberOfBins which means =
that
some bins have a range between two integer values (if max-min <
NumberOfBins) and as a result they are empty.
On the other hand, matlab is setting the scale of the histogram from 0 =
to
255.
I've added the SetHistogramMin() and SetHistogramMax() functions in the
itkListSampleToHistogramGenerator class so you can set these values
manually. Testing on your image with=20
SetNumberOfBins(255);
SetHistogramMin(0);
SetHistogramMax(255);=20
gave me the same results as Matlab.
Let us know if this solves your problem,
Julien
> -----Original Message-----
> From: insight-users-admin at itk.org=20
> [mailto:insight-users-admin at itk.org] On Behalf Of Luis Ibanez
> Sent: Friday, January 23, 2004 12:05 PM
> To: David Llanos; Insight-users at itk.org
> Cc: Julien Jomier
> Subject: [Insight-users] Re: histogram : empty bins
>=20
>=20
>=20
> Hi David,
>=20
> Thanks for pointing this out.
>=20
> This sounds like a bug in the Histogram evaluation.
>=20
> An entry has been logged into the bug traker with ID # 535.
>=20
> http://www.itk.org/Bug/bug.php?op=3Dshow&bugid=3D535&pos=3D0
>=20
>=20
> Regards,
>=20
>=20
> Luis
>=20
>=20
> ------------------
> David Llanos wrote:
>=20
> > I have already gotten debugging and I have finally=20
> discovered of where
> > the bug came in my program:
> > =20
> > when I compute the histogram of the green component of the image=20
> > 10.jpg,
> > I obtain the disordered values
> > =20
> > the correct values, obtained in MATLAB are:
> > =20
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 2
> > 0
> > 12
> > 33
> > 88
> > 189
> > 446
> > 838
> > 1025
> > 966
> > 990
> > 1151
> > 1521
> > 2070
> > 2818
> > 3566
> > 3970
> > 4042
> > 3817
> > 3263
> > 2415
> > 1888
> > 1513
> > 1328
> > 1317
> > 1280
> > 1314
> > 1359
> > 1436
> > 1570
> > 1666
> > 1760
> > 1728
> > 1776
> > 1811
> > 1793
> > 1687
> > 1630
> > 1495
> > 1313
> > 1297
> > 1259
> > 1240
> > 1184
> > 1084
> > 1080
> > 1059
> > 1006
> > 1031
> > 1044
> > 1049
> > 1074
> > 1055
> > 1124
> > 1107
> > 1156
> > 1201
> > 1313
> > 1407
> > 1257
> > 1252
> > 1200
> > 1304
> > 1340
> > 1322
> > 1240
> > 1228
> > 1107
> > 1070
> > 995
> > 1029
> > 1035
> > 1022
> > 1079
> > 1052
> > 1228
> > 1254
> > 1199
> > 1225
> > 1200
> > 1244
> > 1228
> > 1180
> > 1123
> > 1097
> > 1081
> > 1046
> > 1047
> > 969
> > 895
> > 967
> > 959
> > 996
> > 943
> > 1053
> > 1178
> > 1266
> > 1225
> > 1134
> > 967
> > 876
> > 900
> > 906
> > 894
> > 882
> > 868
> > 918
> > 988
> > 939
> > 1062
> > 1032
> > 1109
> > 1025
> > 1089
> > 1047
> > 1111
> > 1084
> > 971
> > 955
> > 891
> > 909
> > 942
> > 1069
> > 1183
> > 1230
> > 1165
> > 1154
> > 1018
> > 988
> > 1065
> > 972
> > 899
> > 1010
> > 967
> > 983
> > 1075
> > 1179
> > 1280
> > 1107
> > 1096
> > 1015
> > 990
> > 971
> > 1049
> > 968
> > 844
> > 929
> > 978
> > 912
> > 1048
> > 1093
> > 1133
> > 1134
> > 1123
> > 1098
> > 1134
> > 1056
> > 1031
> > 947
> > 1015
> > 1115
> > 1212
> > 1339
> > 1338
> > 1401
> > 1341
> > 1266
> > 1234
> > 1259
> > 1202
> > 1192
> > 1170
> > 1146
> > 1342
> > 1520
> > 1589
> > 1454
> > 1442
> > 1511
> > 1352
> > 1358
> > 1421
> > 1428
> > 1560
> > 1721
> > 1826
> > 1944
> > 1959
> > 1838
> > 1845
> > 1826
> > 1959
> > 2088
> > 2448
> > 2543
> > 2488
> > 2598
> > 2695
> > 2779
> > 2994
> > 2984
> > 3084
> > 3816
> > 4253
> > 4712
> > 5549
> > 6365
> > 7207
> > 9448
> > 16624
> > 27997
> > 42054
> > 62072
> > 86036
> > 106521
> > 131514
> > 168615
> > 167306
> > 135628
> > 95033
> > 57209
> > 29339
> > 11533
> > 2425
> > 374
> > 37
> > 3
> > 1
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > and with the next code, i obtainig this:
> > =20
> > unsigned long Histograma[255];
> > for( unsigned int bin=3D0; bin < histogramSize; bin++ ) =20
> > Histograma[bin]=3Dhistogram->GetFrequency( bin, channel );
> > =20
> > [0] 2
> > [1] 0
> > [2] 12
> > [3] 33
> > [4] 88
> > [5] 189
> > [6] 446
> > [7] 838
> > [8] 1025
> > [9] 0
> > [10] 966
> > [11] 990
> > [12] 1151
> > [13] 1521
> > [14] 2070
> > [15] 2818
> > [16] 3566
> > [17] 3970
> > [18] 0
> > [19] 4042
> > [20] 3817
> > [21] 3263
> > [22] 2415
> > [23] 1888
> > [24] 1513
> > [25] 1328
> > [26] 1317
> > [27] 0
> > [28] 1280
> > [29] 1314
> > [30] 1359
> > [31] 1436
> > [32] 1570
> > [33] 1666
> > [34] 1760
> > [35] 1728
> > [36] 0
> > [37] 1776
> > [38] 1811
> > [39] 1793
> > [40] 1687
> > [41] 1630
> > [42] 1495
> > [43] 1313
> > [44] 1297
> > [45] 0
> > [46] 1259
> > [47] 1240
> > [48] 1184
> > [49] 1084
> > [50] 1080
> > [51] 1059
> > [52] 1006
> > [53] 1031
> > [54] 0
> > [55] 1044
> > [56] 1049
> > [57] 1074
> > [58] 1055
> > [59] 1124
> > [60] 1107
> > [61] 1156
> > [62] 1201
> > [63] 0
> > [64] 1313
> > [65] 1407
> > [66] 1257
> > [67] 1252
> > [68] 1200
> > [69] 1304
> > [70] 1340
> > [71] 1322
> > [72] 1240
> > [73] 0
> > [74] 1228
> > [75] 1107
> > [76] 1070
> > [77] 995
> > [78] 1029
> > [79] 1035
> > [80] 1022
> > [81] 1079
> > [82] 0
> > [83] 1052
> > [84] 1228
> > [85] 1254
> > [86] 1199
> > [87] 1225
> > [88] 1200
> > [89] 1244
> > [90] 1228
> > [91] 0
> > [92] 1180
> > [93] 1123
> > [94] 1097
> > [95] 1081
> > [96] 1046
> > [97] 1047
> > [98] 969
> > [99] 895
> > [100] 0
> > [101] 967
> > [102] 959
> > [103] 996
> > [104] 943
> > [105] 1053
> > [106] 1178
> > [107] 1266
> > [108] 1225
> > [109] 0
> > [110] 1134
> > [111] 967
> > [112] 876
> > [113] 900
> > [114] 906
> > [115] 894
> > [116] 882
> > [117] 868
> > [118] 0
> > [119] 918
> > [120] 988
> > [121] 939
> > [122] 1062
> > [123] 1032
> > [124] 1109
> > [125] 1025
> > [126] 1089
> > [127] 0
> > [128] 1047
> > [129] 1111
> > [130] 1084
> > [131] 971
> > [132] 955
> > [133] 891
> > [134] 909
> > [135] 942
> > [136] 1069
> > [137] 0
> > [138] 1183
> > [139] 1230
> > [140] 1165
> > [141] 1154
> > [142] 1018
> > [143] 988
> > [144] 1065
> > [145] 972
> > [146] 0
> > [147] 899
> > [148] 1010
> > [149] 967
> > [150] 983
> > [151] 1075
> > [152] 1179
> > [153] 1280
> > [154] 1107
> > [155] 0
> > [156] 1096
> > [157] 1015
> > [158] 990
> > [159] 971
> > [160] 1049
> > [161] 968
> > [162] 844
> > [163] 929
> > [164] 0
> > [165] 978
> > [166] 912
> > [167] 1048
> > [168] 1093
> > [169] 1133
> > [170] 1134
> > [171] 1123
> > [172] 1098
> > [173] 0
> > [174] 1134
> > [175] 1056
> > [176] 1031
> > [177] 947
> > [178] 1015
> > [179] 1115
> > [180] 1212
> > [181] 1339
> > [182] 0
> > [183] 1338
> > [184] 1401
> > [185] 1341
> > [186] 1266
> > [187] 1234
> > [188] 1259
> > [189] 1202
> > [190] 1192
> > [191] 0
> > [192] 1170
> > [193] 1146
> > [194] 1342
> > [195] 1520
> > [196] 1589
> > [197] 1454
> > [198] 1442
> > [199] 1511
> > [200] 0
> > [201] 1352
> > [202] 1358
> > [203] 1421
> > [204] 1428
> > [205] 1560
> > [206] 1721
> > [207] 1826
> > [208] 1944
> > [209] 1959
> > [210] 0
> > [211] 1838
> > [212] 1845
> > [213] 1826
> > [214] 1959
> > [215] 2088
> > [216] 2448
> > [217] 2543
> > [218] 2488
> > [219] 0
> > [220] 2598
> > [221] 2695
> > [222] 2779
> > [223] 2994
> > [224] 2984
> > [225] 3084
> > [226] 3816
> > [227] 4253
> > [228] 0
> > [229] 4712
> > [230] 5549
> > [231] 6365
> > [232] 7207
> > [233] 9448
> > [234] 16624
> > [235] 27997
> > [236] 42054
> > [237] 0
> > [238] 62072
> > [239] 86036
> > [240] 106521
> > [241] 131514
> > [242] 168615
> > [243] 167306
> > [244] 135628
> > [245] 95033
> > [246] 0
> > [247] 57209
> > [248] 29339
> > [249] 11533
> > [250] 2425
> > [251] 374
> > [252] 37
> > [253] 3
> > [254] 1
> > =20
> > it places me a 0 each 9 values. Do you know which the reason is?
> > =20
> >=20
> >=20
> ----------------------------------------------------------------------
> > --
> >=20
>=20
>=20
>=20
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org=20
> http://www.itk.org/mailman/listinfo/insight-> users
>=20