Libraryless. Click here for Pure Java version (13110L/76K).
1 | static IImageRegion g22_mostOverlappingRegionInOtherImage(IImageRegion region, IImageRegions regions2) {
|
2 | WidthAndHeight image1 = region.image(); |
3 | WidthAndHeight image2 = regions2.image(); |
4 | assertSameSize(image1, image2); |
5 | |
6 | // pixel positions in image 1 region |
7 | int[] pixels = region.pixelsAsIntArray(); |
8 | |
9 | // region matrix of image 2 |
10 | int[] regionMatrix = regions2.regionMatrix(); |
11 | |
12 | // count matching pixels for each image 2 region |
13 | int nRegions = regions2.nRegions(); |
14 | int[] counts = new[nRegions+1]; |
15 | |
16 | for (pos : pixels) |
17 | counts[regionMatrix[pos]]++; |
18 | |
19 | ret regions2.getRegion(indexOfHighest(counts)); |
20 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
| Snippet ID: | #1035926 |
| Snippet name: | g22_mostOverlappingRegionInOtherImage |
| Eternal ID of this version: | #1035926/1 |
| Text MD5: | d6366a512cc527719c483acfcca28d57 |
| Transpilation MD5: | 95d67cb5602af91ffb609580ee2be096 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-08-14 19:47:04 |
| Source code size: | 650 bytes / 20 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 332 / 423 |
| Referenced in: | [show references] |