Code: Select all
#######################################################
## M E A S U R E M E N T A N D A N A L Y S I S
##
## Macro name: interactive measurement of several images
## Required files: round1.zvi, round2.zvi
##
## LOAD IMAGE, DRAW CIRCLES, MEASURE INTERACTIVELY,
## SAVE IMAGE AND CUMULATED DATALIST
##
#######################################################
##
## Remove all open images
Zen.Application.Documents.RemoveAll()
##
## activate IO library
from System.IO import File, Directory, FileInfo
##
## define path and file type
path = "C:\\OAD\\Input\\ZVI Images\\Round"
files = Directory.GetFiles(path,"*.zvi")
##
## loop over all ZVI images in the folder
for i in range(0,files.Length):
file = files[i]
fileInfo = FileInfo(file)
PathAndFile = path + "\\" + fileInfo.Name
## Load and display the image
image = Zen.Application.LoadImage(PathAndFile,False)
Zen.Application.Documents.Add(image)
## Switch to Measurement view
imageView = Zen.Application.DocumentViews.Find(image)
imageView.ActiveViewType = ZenDocumentView.ImageMeasurement
## Pause loop and tell user what to do
Zen.Application.Pause('Switch to Graphics view, Select Keep tool, Select circle tool and draw circles.\nThen press Continue! \nMeasured images will be saved!')
## Generate datalist for first image
if i == 0:
measTableAll = Zen.Measurement.MeasureToTable(image)
## Append data to datalist for further images
if i > 0:
Zen.Measurement.MeasureToTable(image,measTableAll,True)
## Save analyzed image with measurement data automatically as CZI
fileNameWE = image.Name.Substring(0,image.Name.Length-4)
newFileName = fileNameWE + '_measInt' + '.czi'
imageName = "C:\\OAD\\Output\\CZI Images\\" + newFileName
image.Save(imageName)
## Close image (otherwise it cannot be deleted in explorer)
image.Close()
##
## show result data lists with cumulated measurement data
## Save cumulated measurement data list automatically
Zen.Application.Documents.Add(measTableAll)
measTableAll.Save("C:\\OAD\\Output\\CSV Tables\\" + "measTableAll" + ".csv")
##
#######################################################