Libraryless. Click here for Pure Java version (17452L/112K).
sclass JEImageCompressionTest1 { settable BufferedImage originalImage; settable BufferedImage scaledImage; *() { this(screenshot()); } *(BufferedImage *originalImage) {} int rows = 20; int imgHeight = 200; Matrix<Int> m; long dataBytes, dataChars; Matrix<Matrix<Int>> grid; JE_CompressEachElementIndividually<LInt> strat; CompressionSearch_AnyType<IJavaExpr, LLInt> search; CompressionSearch_AnyType<IJavaExpr, LLInt>.Submission winner; S get() { assertNotNull(originalImage); scaledImage = resizeImageToHeight(originalImage, imgHeight); m = imageToMatrix(scaledImage); dataBytes = m.nCells()*4+2; dataChars = dataBytes*2 + l("lInt(\"\")"); print("Matrix ~ " + takeFirst_str(60, m)); print("Trivial comp ~ " + (m.nCells()*8)); grid = matrixToMNGrid_rows(m, rows); // the cells as int matrices L<Matrix<Int>> flat = matrixToList(grid); // the cells as int lists //L<LByte> cells = map intMatrixToByteList_littleEndian(flat); L<LInt> cells = map matrixToList(flat); search = jeCompressionSearch(cells, dataChars); strat = new JE_CompressEachElementIndividually<LInt>() .elementCompressionStrategy(-> new JE_RepElement) .onCompressionFail(ints -> javaObjectToIJavaExpr(ints); //enableScaffolding(search.scheduler()); //enableScaffolding(strat); //print(scaffolding := metaGet(strat, "scaffolding")); search.addStrategy(strat); runProbabilisticForNSeconds(5.0, search); winner = search.bestSubmission(); print(strat.stats()); if (winner != null) { //print("Hard result (score " + result.scoreRatio() + ")", result.checkUnder(hardJERegime()); print(winner); } ret winnerCode(); } S winnerCode() { ret winner == null ?: str(winner.decompressor()); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1033236 | 
| Snippet name: | JEImageCompressionTest1 | 
| Eternal ID of this version: | #1033236/8 | 
| Text MD5: | e8f67ba168fe2aa0d16fe9e4f1ac97f6 | 
| Transpilation MD5: | 20d99603915ba9e227f0e1d6009805e6 | 
| Author: | stefan | 
| Category: | javax / recognition by compression | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2021-10-16 11:21:42 | 
| Source code size: | 1902 bytes / 59 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 511 / 711 | 
| Version history: | 7 change(s) | 
| Referenced in: | #1033242 - JEImageCompressionTest2 [dev.] #1033357 - GridCodec1 [grid-based still image codec, OK, but doesn't use integral image] #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |