import os
import sys, getopt
import PyIPSDK
import PyIPSDK.IPSDKIPLIntensityTransform as itrans
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "Unequalized_Hawkes_Bay_NZ.tif")
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
outputImgPath = os.path.join(tmpPath, "equalization.tif")
outImgMin = 0
outImgMax = 255
try:
opts, args = getopt.getopt(argv,"hi:o:n:x:",["inputImgFilePath=","outputImgFilePath=", "outImgMin=", "outImgMax="])
except getopt.GetoptError:
print('<application_script_filename> [--inputImgFilePath <input_image_file_path>] [--outputImgFilePath <output_image_file_path>] [--outImgMin <min_value>] [--outImgMax <max_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>] [--outImgMin <min_value>] [--outImgMax <max_value>]')
sys.exit(0)
elif opt in ("-i", "--inputImgFilePath"):
inputImgPath = arg
elif opt in ("-o", "--outputImgFilePath"):
outputImgPath = arg
elif opt in ("-n", "--outImgMin"):
outImgMin = float(arg)
elif opt in ("-n", "--outImgMax"):
outImgMax = float(arg)
return inputImgPath, outputImgPath, outImgMin, outImgMax
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
equalizeRange = PyIPSDK.createRange(outImgMin, outImgMax)
outImg = itrans.equalize2dImg(inImg, equalizeRange)
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveTiffImageFile(outputImgPath, outImg)
if __name__ == "__main__":