#for hit in Hits_AfterNMS : print hit # 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
def extractFeatures(ip, params): sift = FloatArray2DSIFT(params) sift.init(FloatArray2D(ip.convertToFloat().getPixels(), ip.getWidth(), ip.getHeight())) features = sift.run() # instances of mpicbg.imagefeatures.Feature return features features1 = extractFeatures(imp1.getProcessor(), p) features2 = extractFeatures(imp2.getProcessor(), p) # Feature locations as points in an ROI # Store feature locations in the Roi manager for visualization later roi_manager = RoiManager() roi1 = PointRoi() roi1.setName("features for cut1") for f in features1: roi1.addPoint(f.location[0], f.location[1]) roi_manager.addRoi(roi1) roi2 = PointRoi() roi2.setName("features for cut2") for f in features2: roi2.addPoint(f.location[0], f.location[1]) roi_manager.addRoi(roi2) # Find matches between the two sets of features # (only by whether the properties of the features themselves match, # not by their spatial location.)