# NB : Hits coordinates have not been corrected for cropping here ! Done in the next for loop # Loop over final hits to generate ROI for hit in Hits_AfterNMS: #print hit if Bool_SearchRoi: # Add offset of search ROI hit['BBox'] = (hit['BBox'][0] + dX, hit['BBox'][1] + dY, hit['BBox'][2], hit['BBox'][3]) # Create detected ROI roi = Roi(*hit['BBox']) roi.setName(hit['TemplateName']) roi.setPosition(i) # set ROI Z-position #roi.setProperty("class", hit["TemplateName"]) image.setSlice(i) image.setRoi(roi) if add_roi: rm.add( None, roi, i ) # Trick to be able to set Z-position when less images than the number of ROI. Here i is an digit index before the Roi Name # Show All ROI + Associate ROI to slices rm.runCommand("Associate", "true") rm.runCommand("Show All with labels") IJ.selectWindow(ImageName) # does not work always
## Stop time here (we dont benchmark display time) Stop = time.clock() Elapsed = Stop - Start # in seconds ListTime.append(Elapsed) ## Loop over final hits to generate ROI, result table... ### for hit in Hits_AfterNMS: if Bool_SearchRoi: # Add the offset of the search ROI hit['BBox'] = (hit['BBox'][0] + dX, hit['BBox'][1] + dY, hit['BBox'][2], hit['BBox'][3]) if add_roi: roi = Roi(*hit['BBox']) roi.setName(hit['TemplateName']) roi.setPosition(i + 1) # set slice position rm.add( None, roi, i + 1 ) # Trick to be able to set slice when less images than ROI. Here i is an digit index before the Roi Name if show_table: Xcorner, Ycorner = hit['BBox'][0], hit['BBox'][1] Xcenter, Ycenter = CornerToCenter(Xcorner, Ycorner, hit['BBox'][2], hit['BBox'][3]) Dico = { 'Image': ImName, 'Template': hit['TemplateName'], 'Xcorner': Xcorner, 'Ycorner': Ycorner, 'Xcenter': Xcenter,