Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1035926 // g22_mostOverlappingRegionInOtherImage

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (13110L/76K).

static IImageRegion g22_mostOverlappingRegionInOtherImage(IImageRegion region, IImageRegions regions2) {
  WidthAndHeight image1 = region.image();
  WidthAndHeight image2 = regions2.image();
  assertSameSize(image1, image2);
  
  // pixel positions in image 1 region
  int[] pixels = region.pixelsAsIntArray();
  
  // region matrix of image 2
  int[] regionMatrix = regions2.regionMatrix();
  
  // count matching pixels for each image 2 region
  int nRegions = regions2.nRegions();
  int[] counts = new[nRegions+1];
  
  for (pos : pixels)
    counts[regionMatrix[pos]]++;
    
  ret regions2.getRegion(indexOfHighest(counts));
}

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: 127 / 171
Referenced in: [show references]