Libraryless. Click here for Pure Java version (15882L/94K).
// S&P, then regions sclass Gazelle22_ImageToRegions { BufferedImage inputImage; BWIntegralImage ii; SnPSettings snpSettings; BWImage posterized; BWImage_FastRegions regions; Map<IImageRegion<BWImage>, Double> scoredRegions; bool wasRun; settable bool withDiagonals; // also walk diagonally? FunctionTimings<S> timings; *(FunctionTimings<S> *timings, BufferedImage *inputImage, SnPSettings *snpSettings) {} Decolorizer decolorizer() { ret snpSettings.decolorizer; } run { set wasRun; var decolorizer = decolorizer(); timings.do(decolorizer != null ? "bwIntegralImage w/decolorizer" : "bwIntegralImage", -> ii = bwIntegralImage_withMeta(inputImage, decolorizer)); timings.do("scaleAndPosterize", -> posterized = scaleAndPosterize(ii, snpSettings)); regions = new BWImage_FastRegions(posterized); regions.collectBounds(); regions.withDiagonals(withDiagonals); timings.do("Regions", regions); } // information about original screenshot if available ScreenShotMeta screenShotMeta() { ret optCast ScreenShotMeta(getMetaSrc(inputImage)); } Pt coordinatesFromScreen(Pt p) { var meta = screenShotMeta(); if (meta == null) null; var r = meta.bounds; if (!r.contains(p)) null; p = translatePt(p, -r.x, -r.y); ret scalePt(p, doubleRatio(snpSettings.pixelRows, r.h)); } Pt coordinatesToScreen(Pt p) { var meta = screenShotMeta(); if (meta == null) null; var r = meta.bounds; ret translatePt(r.x, r.y, scalePt(p, doubleRatio(r.h, snpSettings.pixelRows))); } BWImage_FastRegions regions aka get() { if (!wasRun) run(); ret regions; } int nRegions() { ret regions().nRegions(); } }
Began life as a copy of #1016056
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034028 |
Snippet name: | Gazelle22_ImageToRegions (BufferedImage -> BWIntegralImage -> regions) |
Eternal ID of this version: | #1034028/15 |
Text MD5: | 48840cc6a99ce0f56d9ed1971f9cf1ce |
Transpilation MD5: | 70bc7da09dcf4ead56e1b717876294cc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-25 23:22:36 |
Source code size: | 1803 bytes / 61 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 263 / 464 |
Version history: | 14 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |