The exeRecipe function is used to execute a given recipe on a given image and return the binary mask data and their corresponding measurements.

Arguments

Args:
imagePath: file path to image as a raw string
recipePath: file path to recipe as raw string
cal: calibration factor in units of micrometer per pixel as a float 

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.

Syntax

X = mipar.exeRecipe(imagePath, recipePath, 0); to keep existing calibration factor saved with the recipe
X = mipar.exeRecipe(imagePath, recipePath, cal); to override the existing calibration factor

Examples

# 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.get('LayerName').keys()));                        #measurement names

# retrieve data
binaryOutput = recOutput.get('LayerName').get(binary);      #retrieve binary segmentation
measurementOutput = recOutput.get('LayerName').get('MeasName');     #retrieve image
calibrationOutput = recOutput.get('LayerName').get('cal').get('value');     #retrieve calibration value in units of micrometers per pixel
measurementUnits = recOutput.get('LayerName').get('cal').get('units');   #retrieve the measurement units

# MeasNames can be "Global Measurements":https://www.manula.com/manuals/mipar/user-manual/latest/en/topic/measurements such as: Area, Area Fraction and Number 
# Density it can also be "Feature Measurements":https://www.manula.com/manuals/mipar/user-manual/latest/en/topic/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 ››

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.