Page 1 of 1

Getting percentile values

Posted: 2012-08-24T14:23:30-07:00
by cryptochrome
How can I get the actual pixel values for percentiles in a grayscale image? Using -contrast-stretch is insufficient, because I need the actual values. Once I have the pixel values corresponding to the, say 5th and 95th percentiles from a particular image, I plan to use -level to apply the exact same contrast adjustment to each relevant image. Any help would be appreciated.

Re: Getting percentile values

Posted: 2012-08-24T15:34:09-07:00
by fmw42
I believe that is how -linear-stretch works. See http://www.imagemagick.org/Usage/color_ ... ar-stretch. And looking at the code, it shows it calls levelImage which is effectively -level.

Also see my bash unix script, omnistretch, at the link below. It can do that also. In that script, I simply access the histogram, compute the cumulative histogram and then find the graylevels for any given percent from either end.

Re: Getting percentile values

Posted: 2012-08-25T14:41:54-07:00
by cryptochrome
Sorry, I'm still not sure how I can get out the pixel values simply. Is there really no way to get the cdf of an image without using bash scripts or awk? Maybe you could give an example of how to use -linear-stretch to achieve what I want.

Suppose I have three 16-bit images in a folder: img1.png, img2.png, and img3.png.
I want to get the grayscale values corresponding to the 5th and 95th percentiles of img1.png. Suppose the said grayscale values are 5000 and 54000.
I want to use said grayscale values with -level for each image, so "mogrify -path newFolder -level 5000,54000 *.png".

Thanks.

Re: Getting percentile values

Posted: 2012-08-25T15:21:02-07:00
by fmw42
cryptochrome wrote:Sorry, I'm still not sure how I can get out the pixel values simply. Is there really no way to get the cdf of an image without using bash scripts or awk? Maybe you could give an example of how to use -linear-stretch to achieve what I want.

Suppose I have three 16-bit images in a folder: img1.png, img2.png, and img3.png.
I want to get the grayscale values corresponding to the 5th and 95th percentiles of img1.png. Suppose the said grayscale values are 5000 and 54000.
I want to use said grayscale values with -level for each image, so "mogrify -path newFolder -level 5000,54000 *.png".

Thanks.
I am simply saying that linear-stretch does all what you want. You specify the percentiles you want and it applies level with the graylevels that correspond to those percentiles.

mogrify -path newFolder -format xxx -linear-stretch 5%,95% *.png

Note you have to create the newFolder ahead of time as far as I know. Also I believe that you need to tell IM what format you want for the output. It may default to taking the input image format, but I am not sure.

I know of no way to get cumulative percents from IM. You can get the histogram, but then you have to cumulate the percentiles yourself using bash or some other means.

Re: Getting percentile values

Posted: 2012-08-25T15:58:26-07:00
by cryptochrome
fmw42 wrote:
cryptochrome wrote:Sorry, I'm still not sure how I can get out the pixel values simply. Is there really no way to get the cdf of an image without using bash scripts or awk? Maybe you could give an example of how to use -linear-stretch to achieve what I want.

Suppose I have three 16-bit images in a folder: img1.png, img2.png, and img3.png.
I want to get the grayscale values corresponding to the 5th and 95th percentiles of img1.png. Suppose the said grayscale values are 5000 and 54000.
I want to use said grayscale values with -level for each image, so "mogrify -path newFolder -level 5000,54000 *.png".

Thanks.
I am simply saying that linear-stretch does all what you want. You specify the percentiles you want and it applies level with the graylevels that correspond to those percentiles.

mogrify -path newFolder -format xxx -linear-stretch 5%,95% *.png

Note you have to create the newFolder ahead of time as far as I know. Also I believe that you need to tell IM what format you want for the output. It may default to taking the input image format, but I am not sure.

I know of no way to get cumulative percents from IM. You can get the histogram, but then you have to cumulate the percentiles yourself using bash or some other means.
I don't think that is quite the solution I want. I guess I haven't explained myself well. The percentiles I want are not fixed, instead the pixel values (based on a certain set of percentiles) are fixed. The reason for this is that I need pixels that have the same value in any of the original images to have an equal value in all the output images, independent of the histogram of each individual image. For example, all pixels of value 10000 in the original images might need to have a value of 5000 in the output images. I think I'll end up using python and PIL to calculate the percentiles that I want.

Re: Getting percentile values

Posted: 2012-08-25T16:16:43-07:00
by fmw42
I don't think that is quite the solution I want. I guess I haven't explained myself well. The percentiles I want are not fixed, instead the pixel values (based on a certain set of percentiles) are fixed. The reason for this is that I need pixels that have the same value in any of the original images to have an equal value in all the output images, independent of the histogram of each individual image. For example, all pixels of value 10000 in the original images might need to have a value of 5000 in the output images. I think I'll end up using python and PIL to calculate the percentiles that I want.
-level will not do that even if you compute the correct percentiles. It will stretch some value to full black and full white. So you would need to follow that with a mapping of black and white to whatever desired graylevel you want. That can be done using -fill newvalue -opaque white.

If you know what graylevels you want for the given percentiles, then just do
convert image -linear-stretch 5%,95% -fill lowval -opaque black -fill highval -opaque white resultimage


Perhaps you need something like my mapcolors script at the link below once you know what graylevel ranges you want to go to whatever new ranges.

Re: Getting percentile values

Posted: 2012-08-25T16:34:22-07:00
by cryptochrome
fmw42 wrote: -level will not do that even if you compute the correct percentiles. It will stretch some value to full black and full white. So you would need to follow that with a mapping of black and white to whatever desired graylevel you want. That can be done using -fill newvalue -opaque white.

If you know what graylevels you want for the given percentiles, then just do
convert image -linear-stretch 5%,95% -fill lowval -opaque black -fill highval -opaque white resultimage


Perhaps you need something like my mapcolors script at the link below once you know what graylevel ranges you want to go to whatever new ranges.
Let me try again. Suppose the pixel values corresponding to the percentiles I want are 5000 and 50000. Now I want to stretch each image so that pixels between 5000 and 50000 are stretched to fill the range 0 to 65535, while pixels at or below 5000 become 0, and pixels at or above 50000 become 65535. Is this not what -level does?

Thanks for continuing to try to help me, despite my poor explanations.

Re: Getting percentile values

Posted: 2012-08-25T17:10:03-07:00
by fmw42
cryptochrome wrote:Let me try again. Suppose the pixel values corresponding to the percentiles I want are 5000 and 50000. Now I want to stretch each image so that pixels between 5000 and 50000 are stretched to fill the range 0 to 65535, while pixels at or below 5000 become 0, and pixels at or above 50000 become 65535. Is this not what -level does?
Yes, but if you got 5000 from 5% and 50000 from 95% then you can skip looking up the 5000 and 50000 by just using -linear-stretch 5%,95%. It finds those gray values for you and then applies -level with those gray levels.

That is if you know you want 5% to go to black and 95% to go to white and everything in between to stretch linearly, then you do not have to look up the gray values corresponding to those percentiles.

Re: Getting percentile values

Posted: 2012-08-25T19:02:06-07:00
by cryptochrome
fmw42 wrote:
cryptochrome wrote:Let me try again. Suppose the pixel values corresponding to the percentiles I want are 5000 and 50000. Now I want to stretch each image so that pixels between 5000 and 50000 are stretched to fill the range 0 to 65535, while pixels at or below 5000 become 0, and pixels at or above 50000 become 65535. Is this not what -level does?
Yes, but if you got 5000 from 5% and 50000 from 95% then you can skip looking up the 5000 and 50000 by just using -linear-stretch 5%,95%. It finds those gray values for you and then applies -level with those gray levels.

That is if you know you want 5% to go to black and 95% to go to white and everything in between to stretch linearly, then you do not have to look up the gray values corresponding to those percentiles.
Yeah, but the 5% and 95% levels according to -linear-stretch will be different for different images, depending on each image's histogram, right? This is not what I want. I need the exact same gray values for -level applied to each image. In some images, the black_point I use might only correspond to the 2% level according to -linear-stretch, for example. I guess the equivalent of what I want is to combine all my images into one big image, apply -level, then split them back into individual images.

Re: Getting percentile values

Posted: 2012-08-25T19:56:08-07:00
by fmw42
Yeah, but the 5% and 95% levels according to -linear-stretch will be different for different images, depending on each image's histogram, right? This is not what I want. I need the exact same gray values for -level applied to each image. In some images, the black_point I use might only correspond to the 2% level according to -linear-stretch, for example. I guess the equivalent of what I want is to combine all my images into one big image, apply -level, then split them back into individual images.
If you do not have too many images, you can append them all, apply -linear-stretch, then crop them back. Not a good solution as you lose track of where to crop afterwards, unless all the images are the same size. Then cropping should not be that hard.

I understand now why you want to get the gray levels from the cumulative percentile of the total of all the images. However, I do not think that applying the same graylevels using -level will be optimal for all the images. But that is where I lose you on your ultimate goal.

This will compute a 256 bin cumulative histogram vs graylevel on unix platform using 8-bit grayscale range. The graylevel is first, then the percentile


img="zelda3.jpg"
totpix=`convert $img -format "%[fx:w*h]" info:`
convert $img -depth 8 -format "%c" -define histogram:unique-colors=true histogram:info:- |\
tr -cs '0-9\012' ' ' |\
awk -v totpix="$totpix" '# AWK to generate a cumulative histogram
{ bin[int($2)] += $1 }
END { for (i=0;i<256;i++) {cum += bin/totpix; print i, 100*cum; } } '

Code: Select all

0 0.0305176
1 0.0488281
2 0.0488281
3 0.0793457
4 0.0793457
5 0.0854492
6 0.109863
7 0.115967
8 0.128174
9 0.146484
10 0.177002
11 0.195312
12 0.22583
13 0.244141
14 0.268555
15 0.280762
16 0.311279
17 0.311279
18 0.32959
19 0.341797
20 0.360107
21 0.390625
22 0.396729
23 0.415039
24 0.445557
25 0.482178
26 0.531006
27 0.585938
28 0.646973
29 0.701904
30 0.726318
31 0.769043
32 0.817871
33 0.878906
34 0.933838
35 0.964355
36 1.00098
37 1.0437
38 1.08032
39 1.12915
40 1.2146
41 1.25732
42 1.28174
43 1.33667
44 1.3855
45 1.44653
46 1.52588
47 1.61133
48 1.64795
49 1.68457
50 1.75781
51 1.85547
52 1.9104
53 1.95923
54 2.05688
55 2.13013
56 2.18506
57 2.22778
58 2.33765
59 2.39258
60 2.44751
61 2.53906
62 2.62451
63 2.69165
64 2.78931
65 2.86255
66 2.948
67 3.04565
68 3.13721
69 3.21655
70 3.32642
71 3.41797
72 3.52783
73 3.6377
74 3.75366
75 3.91846
76 4.06494
77 4.21143
78 4.35791
79 4.52271
80 4.66919
81 4.82788
82 4.96826
83 5.08423
84 5.24902
85 5.37109
86 5.51758
87 5.60303
88 5.70679
89 5.88379
90 6.04248
91 6.19507
92 6.31104
93 6.48193
94 6.62842
95 6.89087
96 7.01904
97 7.32422
98 7.49512
99 7.73315
100 8.01392
101 8.20312
102 8.38623
103 8.61206
104 8.83789
105 9.0332
106 9.25293
107 9.52148
108 9.80835
109 10.0464
110 10.2539
111 10.5835
112 10.907
113 11.145
114 11.4014
115 11.676
116 11.9324
117 12.2437
118 12.5183
119 12.793
120 13.1287
121 13.4827
122 13.7268
123 14.0381
124 14.2456
125 14.4836
126 14.8071
127 15.0391
128 15.3198
129 15.6799
130 16.0156
131 16.3635
132 16.7419
133 17.2058
134 17.6025
135 18.0664
136 18.4387
137 18.927
138 19.4092
139 19.9829
140 20.5139
141 21.0388
142 21.5942
143 22.1313
144 22.7112
145 23.3215
146 23.9624
147 24.5667
148 25.1892
149 25.9338
150 26.8738
151 27.7832
152 28.4424
153 29.2603
154 30.0476
155 30.9448
156 31.897
157 32.8247
158 33.9722
159 34.9854
160 36.2366
161 37.4146
162 38.5742
163 39.7278
164 40.7593
165 41.7725
166 42.7002
167 43.7317
168 44.8364
169 46.0999
170 47.1069
171 48.2483
172 49.3103
173 50.2197
174 50.8179
175 51.5747
176 52.2583
177 52.8015
178 53.5461
179 54.4067
180 55.127
181 55.957
182 56.7932
183 57.6355
184 58.4656
185 59.2834
186 60.022
187 60.7788
188 61.615
189 62.3718
190 63.1775
191 64.0381
192 64.8071
193 65.741
194 66.626
195 67.2974
196 68.1946
197 68.8843
198 69.6289
199 70.343
200 70.9534
201 71.6797
202 72.3938
203 73.0774
204 73.7061
205 74.3896
206 75.1953
207 75.9216
208 76.7212
209 77.4597
210 78.1433
211 78.7598
212 79.3884
213 80.1819
214 80.8167
215 81.4148
216 82.196
217 82.8674
218 83.5876
219 84.2468
220 84.8633
221 85.3943
222 85.968
223 86.4319
224 86.9934
225 87.5366
226 88.147
227 88.7207
228 89.2212
229 89.7461
230 90.1855
231 90.6128
232 91.1255
233 91.5894
234 92.0349
235 92.511
236 92.9504
237 93.396
238 93.7622
239 94.0735
240 94.397
241 94.6899
242 94.9524
243 95.2332
244 95.4712
245 95.7275
246 95.9961
247 96.2158
248 96.4478
249 96.6553
250 96.8689
251 97.0886
252 97.3145
253 97.5647
254 97.7966
255 100
Or this will convert the 256 graylevel values to 16-bit range


img="zelda3.jpg"
totpix=`convert $img -format "%[fx:w*h]" info:`
convert $img -depth 8 -format "%c" -define histogram:unique-colors=true histogram:info:- |\
tr -cs '0-9\012' ' ' |\
awk -v totpix="$totpix" '# AWK to generate a cumulative histogram
{ bin[int($2)] += $1 }
END { for (i=0;i<256;i++) {cum += bin/totpix; print 65535*i/255, 100*cum; } } '

Code: Select all

0 0.0305176
257 0.0488281
514 0.0488281
771 0.0793457
1028 0.0793457
1285 0.0854492
1542 0.109863
1799 0.115967
2056 0.128174
2313 0.146484
2570 0.177002
2827 0.195312
3084 0.22583
3341 0.244141
3598 0.268555
3855 0.280762
4112 0.311279
4369 0.311279
4626 0.32959
4883 0.341797
5140 0.360107
5397 0.390625
5654 0.396729
5911 0.415039
6168 0.445557
6425 0.482178
6682 0.531006
6939 0.585938
7196 0.646973
7453 0.701904
7710 0.726318
7967 0.769043
8224 0.817871
8481 0.878906
8738 0.933838
8995 0.964355
9252 1.00098
9509 1.0437
9766 1.08032
10023 1.12915
10280 1.2146
10537 1.25732
10794 1.28174
11051 1.33667
11308 1.3855
11565 1.44653
11822 1.52588
12079 1.61133
12336 1.64795
12593 1.68457
12850 1.75781
13107 1.85547
13364 1.9104
13621 1.95923
13878 2.05688
14135 2.13013
14392 2.18506
14649 2.22778
14906 2.33765
15163 2.39258
15420 2.44751
15677 2.53906
15934 2.62451
16191 2.69165
16448 2.78931
16705 2.86255
16962 2.948
17219 3.04565
17476 3.13721
17733 3.21655
17990 3.32642
18247 3.41797
18504 3.52783
18761 3.6377
19018 3.75366
19275 3.91846
19532 4.06494
19789 4.21143
20046 4.35791
20303 4.52271
20560 4.66919
20817 4.82788
21074 4.96826
21331 5.08423
21588 5.24902
21845 5.37109
22102 5.51758
22359 5.60303
22616 5.70679
22873 5.88379
23130 6.04248
23387 6.19507
23644 6.31104
23901 6.48193
24158 6.62842
24415 6.89087
24672 7.01904
24929 7.32422
25186 7.49512
25443 7.73315
25700 8.01392
25957 8.20312
26214 8.38623
26471 8.61206
26728 8.83789
26985 9.0332
27242 9.25293
27499 9.52148
27756 9.80835
28013 10.0464
28270 10.2539
28527 10.5835
28784 10.907
29041 11.145
29298 11.4014
29555 11.676
29812 11.9324
30069 12.2437
30326 12.5183
30583 12.793
30840 13.1287
31097 13.4827
31354 13.7268
31611 14.0381
31868 14.2456
32125 14.4836
32382 14.8071
32639 15.0391
32896 15.3198
33153 15.6799
33410 16.0156
33667 16.3635
33924 16.7419
34181 17.2058
34438 17.6025
34695 18.0664
34952 18.4387
35209 18.927
35466 19.4092
35723 19.9829
35980 20.5139
36237 21.0388
36494 21.5942
36751 22.1313
37008 22.7112
37265 23.3215
37522 23.9624
37779 24.5667
38036 25.1892
38293 25.9338
38550 26.8738
38807 27.7832
39064 28.4424
39321 29.2603
39578 30.0476
39835 30.9448
40092 31.897
40349 32.8247
40606 33.9722
40863 34.9854
41120 36.2366
41377 37.4146
41634 38.5742
41891 39.7278
42148 40.7593
42405 41.7725
42662 42.7002
42919 43.7317
43176 44.8364
43433 46.0999
43690 47.1069
43947 48.2483
44204 49.3103
44461 50.2197
44718 50.8179
44975 51.5747
45232 52.2583
45489 52.8015
45746 53.5461
46003 54.4067
46260 55.127
46517 55.957
46774 56.7932
47031 57.6355
47288 58.4656
47545 59.2834
47802 60.022
48059 60.7788
48316 61.615
48573 62.3718
48830 63.1775
49087 64.0381
49344 64.8071
49601 65.741
49858 66.626
50115 67.2974
50372 68.1946
50629 68.8843
50886 69.6289
51143 70.343
51400 70.9534
51657 71.6797
51914 72.3938
52171 73.0774
52428 73.7061
52685 74.3896
52942 75.1953
53199 75.9216
53456 76.7212
53713 77.4597
53970 78.1433
54227 78.7598
54484 79.3884
54741 80.1819
54998 80.8167
55255 81.4148
55512 82.196
55769 82.8674
56026 83.5876
56283 84.2468
56540 84.8633
56797 85.3943
57054 85.968
57311 86.4319
57568 86.9934
57825 87.5366
58082 88.147
58339 88.7207
58596 89.2212
58853 89.7461
59110 90.1855
59367 90.6128
59624 91.1255
59881 91.5894
60138 92.0349
60395 92.511
60652 92.9504
60909 93.396
61166 93.7622
61423 94.0735
61680 94.397
61937 94.6899
62194 94.9524
62451 95.2332
62708 95.4712
62965 95.7275
63222 95.9961
63479 96.2158
63736 96.4478
63993 96.6553
64250 96.8689
64507 97.0886
64764 97.3145
65021 97.5647
65278 97.7966
65535 100

Re: Getting percentile values

Posted: 2012-08-26T08:27:40-07:00
by cryptochrome
fmw42 wrote:If you do not have too many images, you can append them all, apply -linear-stretch, then crop them back. Not a good solution as you lose track of where to crop afterwards, unless all the images are the same size. Then cropping should not be that hard.

I understand now why you want to get the gray levels from the cumulative percentile of the total of all the images. However, I do not think that applying the same graylevels using -level will be optimal for all the images. But that is where I lose you on your ultimate goal.

This will compute a 256 bin cumulative histogram vs graylevel on unix platform using 8-bit grayscale range. The graylevel is first, then the percentile
Thanks for providing that code. My images are all exactly the same size, but they're too big and I have way too many of them to append.

I know that using -level in the way I want will not be optimal for every image. I'm making compressed images from a time course, though, and it's important that if a region of the field of view has a constant intensity throughout the time course, then it also has a constant intensity throughout the compressed time course.

Thanks again for sticking with me.

Re: Getting percentile values

Posted: 2012-08-26T11:14:34-07:00
by fmw42
I know that using -level in the way I want will not be optimal for every image. I'm making compressed images from a time course, though, and it's important that if a region of the field of view has a constant intensity throughout the time course, then it also has a constant intensity throughout the compressed time course.
Yes, that makes sense for an animation/movie. Now I understand better.

One way would be to reduces all the images, append them, then run the script to get the percentile values you want from the appended image. That is assuming that all the reduced images can still be appended without being too big. That would give you a close approximation of the gray levels from the percentile.

Then you can run -level on each full image separately. Obviously in your case, you don't need to crop the images from the appended version as you are only interested in the global graylevel vs percentile.

If I were doing this, I would output percent gray level values vs percentile counts. That way it is independent of the IM compile. I usually use percent graylevels with -level low%,hi% in my scripts.

img="zelda3.jpg"
totpix=`convert $img -format "%[fx:w*h]" info:`
convert $img -depth 8 -format "%c" -define histogram:unique-colors=true histogram:info:- |\
tr -cs '0-9\012' ' ' |\
awk -v totpix="$totpix" '# AWK to generate a cumulative histogram
{ bin[int($2)] += $1 }
END { for (i=0;i<256;i++) {cum += bin/totpix; print 100*i/255, 100*cum; } } '

Code: Select all

0 0.0305176
0.392157 0.0488281
0.784314 0.0488281
1.17647 0.0793457
1.56863 0.0793457
1.96078 0.0854492
2.35294 0.109863
2.7451 0.115967
3.13725 0.128174
3.52941 0.146484
3.92157 0.177002
4.31373 0.195312
4.70588 0.22583
5.09804 0.244141
5.4902 0.268555
5.88235 0.280762
6.27451 0.311279
6.66667 0.311279
7.05882 0.32959
7.45098 0.341797
7.84314 0.360107
8.23529 0.390625
8.62745 0.396729
9.01961 0.415039
9.41176 0.445557
9.80392 0.482178
10.1961 0.531006
10.5882 0.585938
10.9804 0.646973
11.3725 0.701904
11.7647 0.726318
12.1569 0.769043
12.549 0.817871
12.9412 0.878906
13.3333 0.933838
13.7255 0.964355
14.1176 1.00098
14.5098 1.0437
14.902 1.08032
15.2941 1.12915
15.6863 1.2146
16.0784 1.25732
16.4706 1.28174
16.8627 1.33667
17.2549 1.3855
17.6471 1.44653
18.0392 1.52588
18.4314 1.61133
18.8235 1.64795
19.2157 1.68457
19.6078 1.75781
20 1.85547
20.3922 1.9104
20.7843 1.95923
21.1765 2.05688
21.5686 2.13013
21.9608 2.18506
22.3529 2.22778
22.7451 2.33765
23.1373 2.39258
23.5294 2.44751
23.9216 2.53906
24.3137 2.62451
24.7059 2.69165
25.098 2.78931
25.4902 2.86255
25.8824 2.948
26.2745 3.04565
26.6667 3.13721
27.0588 3.21655
27.451 3.32642
27.8431 3.41797
28.2353 3.52783
28.6275 3.6377
29.0196 3.75366
29.4118 3.91846
29.8039 4.06494
30.1961 4.21143
30.5882 4.35791
30.9804 4.52271
31.3725 4.66919
31.7647 4.82788
32.1569 4.96826
32.549 5.08423
32.9412 5.24902
33.3333 5.37109
33.7255 5.51758
34.1176 5.60303
34.5098 5.70679
34.902 5.88379
35.2941 6.04248
35.6863 6.19507
36.0784 6.31104
36.4706 6.48193
36.8627 6.62842
37.2549 6.89087
37.6471 7.01904
38.0392 7.32422
38.4314 7.49512
38.8235 7.73315
39.2157 8.01392
39.6078 8.20312
40 8.38623
40.3922 8.61206
40.7843 8.83789
41.1765 9.0332
41.5686 9.25293
41.9608 9.52148
42.3529 9.80835
42.7451 10.0464
43.1373 10.2539
43.5294 10.5835
43.9216 10.907
44.3137 11.145
44.7059 11.4014
45.098 11.676
45.4902 11.9324
45.8824 12.2437
46.2745 12.5183
46.6667 12.793
47.0588 13.1287
47.451 13.4827
47.8431 13.7268
48.2353 14.0381
48.6275 14.2456
49.0196 14.4836
49.4118 14.8071
49.8039 15.0391
50.1961 15.3198
50.5882 15.6799
50.9804 16.0156
51.3725 16.3635
51.7647 16.7419
52.1569 17.2058
52.549 17.6025
52.9412 18.0664
53.3333 18.4387
53.7255 18.927
54.1176 19.4092
54.5098 19.9829
54.902 20.5139
55.2941 21.0388
55.6863 21.5942
56.0784 22.1313
56.4706 22.7112
56.8627 23.3215
57.2549 23.9624
57.6471 24.5667
58.0392 25.1892
58.4314 25.9338
58.8235 26.8738
59.2157 27.7832
59.6078 28.4424
60 29.2603
60.3922 30.0476
60.7843 30.9448
61.1765 31.897
61.5686 32.8247
61.9608 33.9722
62.3529 34.9854
62.7451 36.2366
63.1373 37.4146
63.5294 38.5742
63.9216 39.7278
64.3137 40.7593
64.7059 41.7725
65.098 42.7002
65.4902 43.7317
65.8824 44.8364
66.2745 46.0999
66.6667 47.1069
67.0588 48.2483
67.451 49.3103
67.8431 50.2197
68.2353 50.8179
68.6275 51.5747
69.0196 52.2583
69.4118 52.8015
69.8039 53.5461
70.1961 54.4067
70.5882 55.127
70.9804 55.957
71.3725 56.7932
71.7647 57.6355
72.1569 58.4656
72.549 59.2834
72.9412 60.022
73.3333 60.7788
73.7255 61.615
74.1176 62.3718
74.5098 63.1775
74.902 64.0381
75.2941 64.8071
75.6863 65.741
76.0784 66.626
76.4706 67.2974
76.8627 68.1946
77.2549 68.8843
77.6471 69.6289
78.0392 70.343
78.4314 70.9534
78.8235 71.6797
79.2157 72.3938
79.6078 73.0774
80 73.7061
80.3922 74.3896
80.7843 75.1953
81.1765 75.9216
81.5686 76.7212
81.9608 77.4597
82.3529 78.1433
82.7451 78.7598
83.1373 79.3884
83.5294 80.1819
83.9216 80.8167
84.3137 81.4148
84.7059 82.196
85.098 82.8674
85.4902 83.5876
85.8824 84.2468
86.2745 84.8633
86.6667 85.3943
87.0588 85.968
87.451 86.4319
87.8431 86.9934
88.2353 87.5366
88.6275 88.147
89.0196 88.7207
89.4118 89.2212
89.8039 89.7461
90.1961 90.1855
90.5882 90.6128
90.9804 91.1255
91.3725 91.5894
91.7647 92.0349
92.1569 92.511
92.549 92.9504
92.9412 93.396
93.3333 93.7622
93.7255 94.0735
94.1176 94.397
94.5098 94.6899
94.902 94.9524
95.2941 95.2332
95.6863 95.4712
96.0784 95.7275
96.4706 95.9961
96.8627 96.2158
97.2549 96.4478
97.6471 96.6553
98.0392 96.8689
98.4314 97.0886
98.8235 97.3145
99.2157 97.5647
99.6078 97.7966
100 100
How many images do you have and how big are they in widthxheight? Are they grayscale or color. The above code only works on grayscale images. Presumably you would convert each image to grayscale, reduce and append, then run the code.

It is conceivable that a script could be created that would loop over each image, get the normalized cumulative histogram for each image and combine in a running average to produce the total cumulative histogram.

Re: Getting percentile values

Posted: 2012-09-01T18:22:24-07:00
by fmw42
I just finished a new script, cumhist, to generate the combined cumulative histogram for some arbitrary number of images. It can be found at the link below.