Acquire an image and save it

Post your acquisition-related questions and macros here
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Acquire an image and save it

Post by user-4 »

Code: Select all

#######################################################
## A C Q U I S I T I O N
##
## SNAP IMAGE, SAVE IMAGE
## 
#######################################################
##
##
## Remove all open documents
Zen.Application.Documents.RemoveAll()
##
## Show live image
Zen.Acquisition.StartLive()
## Set exposure time (AutoExposure)
Zen.Acquisition.AutoExposure()
Zen.Application.Pause("Search field of interest and focus image!")
## Snap image
image = Zen.Acquisition.AcquireImage()
Zen.Application.Documents.Add(image)
## Close live image
Zen.Acquisition.StopLive()
##
## Save the image interactively with Save as dialog (File menu)
Zen.Application.Save(image)
##
#######################################################


#######################################################
## SOME ALTERNATIVES TO SAVE AN IMAGE
## 
#######################################################
##
## Save an image in a certain folder automatically
#Zen.Application.Save(image,'C:\\OAD\\Output\\CZI Images\\MyImage.czi') 
##
## Save an image in a certain folder interactively 
#Zen.Application.Save(image,'C:\\OAD\\Output\\CZI Images\\MyImage.czi',True)
##
#######################################################
user-3089
Posts: 2
Joined: Thu Jan 01, 1970 1:00 am

Possibility to acquire image through .Net

Post by user-3089 »

Is there a way to acquire the czi file through .NET (c#) ?

Can I call the python script directly or even better, is there an API to get the image from the camera ?
user-6
Posts: 382
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6 »

Dear roelanb,

we forwarded your question to our specialists. Due to the holiday time, please allow us some days for answering.

Thanks!
user-3089
Posts: 2
Joined: Thu Jan 01, 1970 1:00 am

Hi,

Post by user-3089 »

Any news on this ?
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello roelanb,

sorry, but you cannot call the python script directly and there is no API to get the image from the camera. ZEN 'in between' is always needed and ZEN itself relies on other mechanisms 'underneath'.
user-5202
Posts: 1
Joined: Thu Jan 01, 1970 1:00 am

Saving as 16bit tiff

Post by user-5202 »

When I use this to save tiff files, they are 8bit tiffs. However the camera (and software) is acquiring 16bit images. Is there another function call or option to specify the image output resolution?

Thanks
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello bakerta,

this is not possible via this simple save method.

For writing more sophisticated output images please use the export capabilities of ZEN blue.

The following code gives you a rough idea how to work with the export when a setting of the function has been already saved via the GUI.

Code: Select all

# Generate a container for the SingleFileExportSetting
functionsetting = Zen.Processing.Utilities.Settings.SingleFileExportSetting()

# Load the SingleFileExportSetting that has been saved before by the user via ZEN-GUI
functionsetting.Load(‘MySeting”,ZenSettingDirectory.User)

# Prepare Filename
fileName = image.Name.Substring(0,image.Name.Length-4)

# Execute the Export-Function for an Image with a given SingleFileExportSetting
Zen.Processing.Utilities.ExportSingleFile(image,functionsetting,fileName,newPath)
user-5157
Posts: 2
Joined: Thu Jan 01, 1970 1:00 am

Repeat Acquisition-Save-Close

Post by user-5157 »

I would like to automatically repeat the 1-3) processes below:

1) Acquire an image
2) Save the image
3) Close the image

I tested
###
while i < nRepeat:
image = Zen.Acquisition.Execute(exp)
Zen.Application.Save(image)
Zen.Application.Documents.RemoveAll()
image.Close()
i = i + 1
###

, but it seems that the memory usage by ZEN gradually increases with repeating. This results in a significant delay in the system after hundreds of repeats. I suspect that the memory is not completely released after the image is closed. Do you have any solutions? Thanks.
user-9
Posts: 82
Joined: Thu Jan 01, 1970 1:00 am

Post by user-9 »

1) Acquire an image
2) Save the image
3) Close the image

, but it seems that the memory usage by ZEN gradually increases with repeating.
This memory problem is solved in the new release ZEN 2.3.
user-5157
Posts: 2
Joined: Thu Jan 01, 1970 1:00 am

Post by user-5157 »

We tested with ZEN 2.3, but still have this problem.
Post Reply