Transpiled version (5123L) is out of date.
1 | static BWImage iBWAutoContrast(IBWImage bw) { |
2 | ret iBWAutoContrast(bw, 0f); |
3 | } |
4 | |
5 | // def value is usually irrelevant |
6 | static BWImage iBWAutoContrast(IBWImage bw, float def) { |
7 | if (bw == null) null; |
8 | int w = bw.getWidth(), h = bw.getHeight(); |
9 | float min = 1, max = 0; |
10 | for y to h: for x to w: { |
11 | float f = bw.getFloatPixel(x, y); |
12 | min = min(min, f); |
13 | max = max(max, f); |
14 | } |
15 | if (min == max) ret new BWImage(w, h, def); |
16 | float factor = floatRatio(1, max-min); |
17 | BWImage bw2 = new BWImage(w, h); |
18 | for y to h: for x to w: |
19 | bw2.setPixel(x, y, (bw.getFloatPixel(x, y)-min)*factor); |
20 | ret bw2; |
21 | } |
Began life as a copy of #1015507
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027296 |
Snippet name: | iBWAutoContrast - uses actual min and max |
Eternal ID of this version: | #1027296/4 |
Text MD5: | c84acc2120f703847e7a36cd70faf024 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-01 00:02:49 |
Source code size: | 624 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 189 / 280 |
Version history: | 3 change(s) |
Referenced in: | [show references] |