import os
import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
img2d1 = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_UInt16, 487, 532)
geometry2d1 = img2d1.getGeometry()
sizeX2d1 = img2d1.getSizeX()
sizeY2d1 = img2d1.getSizeY()
bufferType2d1 = img2d1.getBufferType()
img3d1 = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Binary, 150, 125, 97)
sizeZ3d1 = img3d1.getSizeZ()
imgRgb1 = PyIPSDK.createImageRgb(PyIPSDK.eImageBufferType.eIBT_UInt8, 512, 480)
sizeCRgb1 = imgRgb1.getSizeC()
imgSeq1 = PyIPSDK.createImageSeq(PyIPSDK.eImageBufferType.eIBT_Real32, 100, 120, 150)
sizeTSeq1 = imgSeq1.getSizeT()
geometry2d2 = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_UInt16, 487, 532)
img2d2 = PyIPSDK.createImage(geometry2d2)
geometry3d2 = PyIPSDK.geometry3d(PyIPSDK.eImageBufferType.eIBT_Binary, 150, 125, 97)
img3d2 = PyIPSDK.createImage(geometry3d2)
geometryRgb2 = PyIPSDK.geometryRgb2d(PyIPSDK.eImageBufferType.eIBT_UInt8, 512, 480)
imgRgb2 = PyIPSDK.createImage(geometryRgb2)
geometrySeq2 = PyIPSDK.geometrySeq2d(PyIPSDK.eImageBufferType.eIBT_Binary, 100, 120, 150)
imgSeq2 = PyIPSDK.createImage(geometrySeq2)
tiffImg2d1 = PyIPSDK.loadTiffImageFile(os.path.join(imagesSamplePath, "blobs_483x348_UInt8.tif"))
tiffImg3d1 = PyIPSDK.loadTiffImageFile(os.path.join(imagesSamplePath, "porosity_125x97x47_UInt16.tif"))
tiffImgSeq1 = PyIPSDK.loadTiffImageFile(os.path.join(imagesSamplePath, "porosity_125x97x47_UInt16.tif"),
PyIPSDK.eTiffDirectoryMode.eTDM_Temporal)
tiffImgBin2d1 = PyIPSDK.loadTiffImageFile(os.path.join(imagesSamplePath, "blobs3d_483x348x31_Binary.tif"),
PyIPSDK.eTiffDirectoryMode.eTDM_Volume,
PyIPSDK.eTiffBufferMode.eTBM_Binary)
tiffImgBin2d1 = PyIPSDK.loadTiffImageFile(os.path.join(imagesSamplePath, "blobs3d_483x348x31_Label.tif"),
PyIPSDK.eTiffDirectoryMode.eTDM_Volume,
PyIPSDK.eTiffBufferMode.eTBM_Label)
tiffOutputPath3d1 = os.path.join(tmpPath, "new_name_for_tiffImg3d1.tif")
PyIPSDK.saveTiffImageFile(tiffOutputPath3d1, tiffImg3d1)
print("Image tiffImg3d1 saved to path : " + tiffOutputPath3d1)
multiTiffImg3d1 = PyIPSDK.loadTiffImageFiles(os.path.join(imagesSamplePath, "sequence1"),
"porosity_125x97x47_UInt16_page_*.tif",
PyIPSDK.eTiffDirectoryMode.eTDM_Volume)
print("Multi tiff image file resulting z size : " + str(multiTiffImg3d1.getSizeZ()))
rawGeometry1 = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_Binary, 256, 256)
rawImg1 = PyIPSDK.loadRawImageFile(os.path.join(imagesSamplePath, "MorphoBin2d1.raw"), rawGeometry1)
rawOutputPath1 = os.path.join(tmpPath, "new_name_for_imgRaw1.raw")
PyIPSDK.saveRawImageFile(rawOutputPath1, rawImg1)
print("Image imgRaw1 saved to path : " + rawOutputPath1)
inSE = PyIPSDK.circularSEXYInfo(8)
outImg1 = morpho.erode2dImg(tiffImg2d1, inSE)