Libraryless. Click here for Pure Java version (11165L/64K).
srecord noeq Hi15ImageStreaks(Hi15Image inputImage) { // pixel indices of streak ends new IntBuffer streakData; int[] lineStarts; gettable int w; run { var streakData = this.streakData; int w = this.w = inputImage.w(), h = inputImage.h(); lineStarts = new int[h+1]; short[] pixels = inputImage.pixels; int iPixel = 0; for y to h: { lineStarts[y] = streakData.size(); int lineEnd = iPixel+w; while (iPixel < lineEnd) { short color = pixels[iPixel]; do ++iPixel; while (iPixel < lineEnd && pixels[iPixel] == color); streakData.add(iPixel); } } lineStarts[l(lineStarts)-1] = streakData.size(); } selfType runAndReturn() { run(); this; } int nStreaks() { ret streakData.size(); } int h() { ret lineStarts.length-1; } int lineEnd(int y) { ret lineStarts[y+1]; } L<Rect> streaksAsRects() { ret listFromFunction(nStreaks(), iStreak -> { int iPixel = iStreak == 0 ? 0 : streakData.get(iStreak-1); int jPixel = streakData.get(iStreak++); int w = w(); ret rect(iPixel % w, iPixel/w, jPixel-iPixel, 1); }); } }
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036091 |
Snippet name: | Hi15ImageStreaks |
Eternal ID of this version: | #1036091/19 |
Text MD5: | 5b954d5a669571d42f8873dbf190cabc |
Transpilation MD5: | 30c4e796a9e0929fa691b1952f9b00d9 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-12 17:40:54 |
Source code size: | 1221 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 148 / 273 |
Version history: | 18 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |