Esempio n. 1
0
def decode_roi(roi_file):
    roi_obj = RoiDecoder(roi_file)
    x = roi_obj.getRoi().getPolygon().getBounds().x
    y = roi_obj.getRoi().getPolygon().getBounds().y
    width = roi_obj.getRoi().getPolygon().getBounds().width
    height = roi_obj.getRoi().getPolygon().getBounds().height
    return x, y, width, height
def roisFromFile(filePath):
	""" Get rois ROI[] from an roi file encoded by imagej """
	rois = []
	isZip = zipfile.is_zipfile(filePath)
	if isZip:
		print("It is a zip-file")
		zf = zipfile.ZipFile(filePath, 'r')
		print zf.namelist()
		for filename in zf.namelist():
			try:
				roiFile = zf.read(filename)
				rd = RoiDecoder(roiFile)
				roi = rd.getRoi()
				rois.append(roi)
			except KeyError:
				print 'ERROR: Did not find %s in zip file' % filename
	else:
		rd = RoiDecoder(filePath)
		rois.append(rd.getRoi())
	return(rois)
}
Method = Dico_Method[method]

# Initialise time
ListTime = []

# Initialise list of templates (rather than opening them for every image iteration)
List_Template = [
    IJ.openImage(templ_file.getPath()) for templ_file in template_files
]

### Search ROI ? ###
# Check if there is a searchRoi
if roi_file:
    from ij.io import RoiDecoder
    searchRoi = RoiDecoder.open(roi_file.getPath())
else:
    searchRoi = None

# Check if it is a rectangular one
if searchRoi and searchRoi.getTypeAsString() == "Rectangle":
    Bool_SearchRoi = True
else:
    Bool_SearchRoi = False

# Define Offset for BBox if proper searchRoi
if Bool_SearchRoi:
    dX = searchRoi.getXBase()
    dY = searchRoi.getYBase()
else:
    dX = dY = 0
Esempio n. 4
0
        raise Exception('The expected number of object should be at least 1')

    if score_threshold < 0 or score_threshold > 1:
        raise Exception('The score threshold should be in range [0,1]')

    #if tolerance<0 or tolerance>1:
    #	raise Exception('Tolerance should be in range [0,1]')

    if max_overlap < 0 or max_overlap > 1:
        raise Exception('The max overlap should be in range [0,1]')

    ### Search ROI ? ###
    # Check if there is a searchRoi
    if RoiPath:
        from ij.io import RoiDecoder
        searchRoi = RoiDecoder.open(RoiPath)
    else:
        searchRoi = None

    # Check if it is a rectangular one
    if searchRoi and searchRoi.getTypeAsString() == "Rectangle":
        Bool_SearchRoi = True
        dX = int(searchRoi.getXBase())
        dY = int(searchRoi.getYBase())

    else:
        Bool_SearchRoi = False
        dX = dY = 0

    ## File or Folder
    # Template(s)