IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
# [DocSampleImports]
import os
import PyIPSDK
import PyIPSDK.IPSDKIPLGeometricTransform as gtrans
# [DocSampleImports]
# [DocSampleLoadImage]
# opening of input image
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "IPSDK_flyer1.tif")
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# [DocSampleLoadImage]
# [DocSampleInputDataSet]
# we define a 2d mapping between 4 points of input image and target points
# for output image
# on output we want to get a rectangular view
targetWidth = 400
targetHeight = 550
inPtColl = [[327, 83],
[697, 216],
[459, 763],
[29, 552]]
outPtColl = [[100, 100],
[100+targetWidth, 100],
[100+targetWidth, 100+targetHeight],
[100, 100+targetHeight]]
# [DocSampleInputDataSet]
# [DocSampleEstimation]
# we compute associated homography
transform, res = PyIPSDK.homographyTransform2dSimpleEstimation(inPtColl, outPtColl)
# [DocSampleEstimation]
# [DocSampleApplyOp]
# application of warping transform
outImg = gtrans.warp2dImg(inImg, transform)
# [DocSampleApplyOp]
# [DocSampleSaveImage]
# save generated image
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
outputImgPath = os.path.join(tmpPath, "warp2dImg.tif")
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveTiffImageFile(outputImgPath, outImg)
# [DocSampleSaveImage]