import os
import sys, getopt
import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "MorphoBin2d1.raw")
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
outputImgPath = os.path.join(tmpPath, "boundary2d_res.raw")
sizeX = 256
sizeY = 256
try:
opts, args = getopt.getopt(argv,"hi:o:x:y:",["inputImgFilePath=","outputImgFilePath=","imgXSz=","imgYSz="])
except getopt.GetoptError:
print('<application_script_filename> [--inputImgFilePath <input_image_file_path> --imgXSz <image_x_size> --imgYSz <image_y_size>] [--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> --imgXSz <image_x_size> --imgYSz <image_y_size>] [--outputImgFilePath <output_image_file_path>]')
sys.exit(0)
elif opt in ("-i", "--inputImgFilePath"):
inputImgPath = arg
elif opt in ("-o", "--outputImgFilePath"):
outputImgPath = arg
elif opt in ("-x", "--imgXSz"):
sizeX = int(arg)
elif opt in ("-y", "--imgYSz"):
sizeY = int(arg)
return inputImgPath, outputImgPath, sizeX, sizeY
imgGeometry = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_Binary, sizeX, sizeY)
inImg = PyIPSDK.loadRawImageFile(inputImgPath, imgGeometry)
outImg = morpho.boundary2dImg(inImg)
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveRawImageFile(outputImgPath, outImg)
if __name__ == "__main__":