import os
import sys, getopt
import PyIPSDK
import PyIPSDK.IPSDKIPLLogical as logic
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "Lena_510x509_UInt8.tif")
maskImgFilePath = os.path.join(imagesSamplePath, "binary_mask.tif")
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
outputImgPath = os.path.join(tmpPath, "mask.tif")
try:
opts, args = getopt.getopt(argv,"hi:m:o:",["inputImgFilePath=","outputImgFilePath=","maskImgFilePath="])
except getopt.GetoptError:
print('<application_script_filename> [--inputImgFilePath <input_image_file_path>] [--maskImgFilePath <mask_image_file_path] [--outputImgFilePath <output_image_file_path>]')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('<application_script_filename> [--inputImgFilePath <input_image_file_path>] [--maskImgFilePath <mask_image_file_path] [--outputImgFilePath <output_image_file_path>]')
sys.exit(0)
elif opt in ("-i", "--inputImgFilePath"):
inputImgPath = arg
elif opt in ("-m", "--maskImgFilePath"):
inputImgPath = arg
elif opt in ("-o", "--outputImgFilePath"):
outputImgPath = arg
return inputImgPath, maskImgFilePath, outputImgPath
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
maskImg = PyIPSDK.loadTiffImageFile(maskImgFilePath)
outImg = logic.maskImg(inImg, maskImg)
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveTiffImageFile(outputImgPath, outImg)
if __name__ == "__main__":