Transpiled version (11068L) is out of date.
// images must have same size static FloatBWImage preciseAverageOfBinaryImages(L<? extends IBinaryImage> images) { int n = l(images); if (n == 0) null; var it = iterator(images); var img = it.next(); int w = img.getWidth(), h = img.getHeight(); int[] pixels = new[w*h]; int nBytes = (w*h+7)/8; var pingSource = pingSource(); while (true) { ping(pingSource); Image2B realizedImage = img.toImage2B(); byte[] imgPixels = realizedImage.pixels; int j = 0; for i to nBytes: { int b = imgPixels[i]; for bit to 8: { ifdef preciseAverageOfBinaryImages_useIf // This version is half as fast (don't set this flag) if ((b & 1) != 0) pixels[i*8+bit]++; endifdef ifndef preciseAverageOfBinaryImages_useIf pixels[j++] += b & 1; endifndef b >>= 1; } } if (!it.hasNext()) break; img = it.next(); } float[] floats = new[w*h]; double factor = 1.0/n; for i over pixels: floats[i] = (float) (pixels[i]*factor); ret new FloatBWImage(w, h, floats); }
Began life as a copy of #1035825
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1035846 |
Snippet name: | preciseAverageOfBinaryImages - as FloatBWImage |
Eternal ID of this version: | #1035846/11 |
Text MD5: | 1c2356a27782b91a98d2017451a2751e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-04 20:46:22 |
Source code size: | 1134 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 128 / 206 |
Version history: | 10 change(s) |
Referenced in: | [show references] |