Count number of pixels above a threshold value (5000)

Discuss questions and projects related to processing of imaging data here
Post Reply
Anand Ranjan
Posts: 14
Joined: Wed Dec 02, 2020 7:53 pm

Count number of pixels above a threshold value (5000)

Post by Anand Ranjan »

Hi,
can Zen analyze a 16-bit image to count the number of pixels with a value above a certain threshold (like 5000)? So far we have used Zen for controlling the Axio Observer microscope and only recently started using the image acquisition module. At the beginning of our imaging experiment, we take four snapshots of different Z planes. We need help for the next step in the macro - analyze the four images from different Z planes to find the image with a maximum number of pixels above 5000 threshold value, and select that Z plane for the rest of image acquisition.

We are taking snapshots instead of using the Z-stack feature of Zen, as the continuous laser exposure during Z-stack bleaches the sample. The exposure during snapshots for each plane is only 10 ms and the fluorophore bleach is minimal.

Here is our macro so far-

## Snapshot of 1st Z plane

experiment1 = Zen.Acquisition.Experiments.GetByName("JF552.czexp")
image1 = Zen.Acquisition.AcquireImage(experiment1)
Zen.Application.Documents.Add(image1)

## Snapshot of 2nd Z plane

focPos = Zen.Devices.Focus.ActualPosition
newfocPos = focPos + 40
Zen.Devices.Focus.MoveTo(newfocPos)

experiment2 = Zen.Acquisition.Experiments.GetByName("Jf552.czexp")
image2 = Zen.Acquisition.AcquireImage(experiment2)
Zen.Application.Documents.Add(image2)

## Snapshot of 3rd Z plane

newfocPos = focPos + 80
Zen.Devices.Focus.MoveTo(newfocPos)

experiment3 = Zen.Acquisition.Experiments.GetByName("DIC.czexp")
image3 = Zen.Acquisition.AcquireImage(experiment3)
Zen.Application.Documents.Add(image3)

## Snapshot of 4th Z plane

newfocPos = focPos + 120
Zen.Devices.Focus.MoveTo(newfocPos)

experiment4 = Zen.Acquisition.Experiments.GetByName("DIC.czexp")
image4 = Zen.Acquisition.AcquireImage(experiment4)
Zen.Application.Documents.Add(image4)

Thank you very much for your guidance.
Anand
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Count number of pixels above a threshold value (5000)

Post by CarlZeissMicroscopy3 »

Hello Anand Ranjan,

there are two ways to do that.

The primary approach is to use the analysis package with its analysis wizard.
In step 3 you can set the threshold between e.g. 5000 and 65535.
In step 6 'Classes 1' is selected, then click on Edit, finally double click on 'Area Unscaled' for calculation.
With this analysis setting you will get a Table with the value 'Area Unscaled' of the image selected.
The 'Area Unscaled' corresponds with the number of pixels having a value between 5000 and 65535.

The secondary approach is via processing.
The function Threshold allows to set the low and high value to e.g. 5000 and 65535.
With 'create binary' selected the output is an binary image which 'shows' values between 5000 and 65535.
Meng Pu
Posts: 1
Joined: Mon Mar 07, 2022 11:36 pm

Re: Count number of pixels above a threshold value (5000)

Post by Meng Pu »

Hi,

I have a related question, I acquired a multi-channel image by LSM980 with the set up of 8 bit. But my following up analysis require a 16 bit TIFF with 65,000 shades of grayscale. Is it possible to export 8 bit CZI to 16 bit TIFF? Does the 8 bit CZI only produce 8 bit TIFF?

Thank you,

Best,

Meng
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Count number of pixels above a threshold value (5000)

Post by CarlZeissMicroscopy3 »

Hello Meng Pu,

please have a look at the Processing tab and use function 'Change Pixel Type'.

In OAD you can call

Code: Select all

imageGray16 = Zen.Processing.Utilities.ChangePixelType(imageGray8, ZenPixelType.Gray16)
You can use 'Image Export' (again Processing tab) to export the image.
Please be sure to enable 'Show All' so that all features can be seen.
Needless to say that 'Convert to 8 bit' has to be disabled in your case.

In OAD the macro looks like

Code: Select all

processingsetting = Zen.Processing.Utilities.Settings.SingleFileExportSetting(ZenExportFileType.JPEG)
processingsetting.Compression = ZenTiffCompression.None
processingsetting.ConvertTo8Bit = False
processingsetting.DestinationFolder = r'C:\Users\...'
processingsetting.OriginalData = True
...
Zen.Processing.Utilities.ExportSingleFile(imageGray16, processingsetting)
In both cases it is possible use the Macro Recorder to generate the macro code for you!

I hope this helps.
oilu miun
Posts: 1
Joined: Wed Nov 22, 2023 11:11 am

Re: Count number of pixels above a threshold value (5000)

Post by oilu miun »

Macro Recorder has helped me a lot!
Walter Lewis
Posts: 1
Joined: Fri Nov 24, 2023 5:19 am

Re: Count number of pixels above a threshold value (5000)

Post by Walter Lewis »

I have the same problem and it also worked for me.
Sonia Khan
Posts: 1
Joined: Tue Sep 19, 2023 5:48 pm

Re: Count number of pixels above a threshold value (5000)

Post by Sonia Khan »

Book ISLMBAD Call Girls in Islamabad from and have pleasure of best with independent Escorts in Islamabad, whenever you want. Call and Book VIP Models. https://islamabad.islamabadgirls.xyz/
green smith
Posts: 1
Joined: Tue Dec 05, 2023 2:20 pm

Re: Count number of pixels above a threshold value (5000)

Post by green smith »

# Counting pixels above a specified threshold in the image to analyze and download high-intensity regions. https://picsartapk.net/picsart-app-for-ios/
Post Reply