code: func (d *Detector) merge(detectedRegions Regions, mergeRegions [][]int) {
  	var newDetectedRegions Regions
  
  	// merging detected regions
  	for index, region := range mergeRegions {
  		if len(newDetectedRegions) >= index {
  			newDetectedRegions = append(newDetectedRegions, Region{})
  		}
  		for _, r := range region {
  			newDetectedRegions[index] = append(newDetectedRegions[index], detectedRegions[r]...)
  			detectedRegions[r] = Region{}
  		}
  	}
  
  	// push the rest of the regions to the newDetectedRegions array
  	// (regions without merging)
  	for _, region := range detectedRegions {
  		if len(region) > 0 {
  			newDetectedRegions = append(newDetectedRegions, region)
  		}
  	}
  
  	// clean up
  	d.clearRegions(newDetectedRegions)
  }
docs: // function for merging detected regions