exeRecipe function is used to execute a given recipe on a given image and return the binary mask data and their corresponding measurements.
Args: image: file path to image as a raw string or image matrix. For companion images input a list of raw strings or image matrices recipePath: file path to recipe as raw string cal: calibration factor in units of micrometer per pixel as a float (optional as of 3.2.3) Returns: recOutput: dictionary variable that contains the binary masks of segmentation and measurements. Binaries can be retrieved by calling the layer and 'binary' key and measurements are retrieved by calling the layer name and the measurement key.
X = mipar.exeRecipe(imagePath, recipePath) #to keep existing calibration factor saved with the recipe X = mipar.exeRecipe(imagePath, recipePath, cal) #to override the existing calibration factor
# initialize engine and licence manager import miparAPI mipar = miparAPI.initialize() mipar.startLicenseMan(nargout = 0) # image and recipe paths recipePath = r'C:\Users\USER\Documents\Python\ExampleRecipe.rcp' imagePath = r'C:\Users\USER\Documents\Python\\ExampleImage.png' # execute Recipe recOutput = mipar.exeRecipe(imagePath, recipePath, 0) # retrieve dictionary keys print(list(recOutput.keys())) #layer names print(list(recOutput['LayerName'].keys())) #measurement names print(list(recOutput['LayerName']['featMeas'].keys()) #retrieve feature measurement keys # retrieve data binaryOutput = recOutput.['LayerName']['binary'] #retrieve binary segmentation measurementOutput = recOutput['LayerName']['MeasName'] #retrieve global measurement featureMeasurementOutput = recOutput['LayerName']['featMeas']['MeasName']._data #retrieve feature measurement keys calibrationOutput = recOutput['LayerName']['cal']['value'] #retrieve calibration value in units of micrometers per pixel measurementUnits = recOutput['LayerName']['cal']['units'] #retrieve the measurement units messages = recOutput['Messages'] #retrieve messages, warnings, and errors from recipe execution. Present in v3.2.3 and later # MeasNames can be Global Measurements such as: Area, Area Fraction and Number Density. # It can also be Feature Measurements statistics such as: Mean Caliper Diameter, Min Roughness, Max Equivalent Diameter or StdDev Area Fraction. # The notation is underscored, for example the key for Global Number Density is Number_Density and the key for Mean Feature Caliper Diameter is Mean_Caliper_Diameter. # It is recommended to pull the keys of measurements to get a complete list of measurements in the recipe. # terminate engine mipar.terminate()
Need more help with this?
Chat with an expert now ››