import os
import sys, getopt
import PyIPSDK
import PyIPSDK.IPSDKIPLArithmetic as arithm
import PyIPSDK.IPSDKIPLFiltering as filter
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "Lena_510x509_UInt8.tif")
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
outputImgPath = os.path.join(tmpPath, "gradientNorm.tif")
inStdDev = 3
try:
opts, args = getopt.getopt(argv,"hi:o:s:",["inputImgFilePath=","outputImgFilePath=", "inStdDev="])
except getopt.GetoptError:
print('<application_script_filename> [--inputImgFilePath <input_image_file_path>] [--outputImgFilePath <output_image_file_path>] [--inStdDev <std_dev_value>]')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('<application_script_filename> [--inputImgFilePath <input_image_file_path>] [--outputImgFilePath <output_image_file_path>] [--inStdDev <std_dev_value>]')
sys.exit(0)
elif opt in ("-i", "--inputImgFilePath"):
inputImgPath = arg
elif opt in ("-o", "--outputImgFilePath"):
outputImgPath = arg
elif opt in ("-s", "--inStdDev"):
inStdDev = float(arg)
return inputImgPath, outputImgPath, inStdDev
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
gradImgX, gradImgY = filter.gaussianGradient2dImg(inImg, inStdDev);
outImg = arithm.l2Norm2Img(gradImgX, gradImgY);
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveTiffImageFile(outputImgPath, outImg)
if __name__ == "__main__":