View simultaneously external mask on top of original image

Discuss questions and projects related to processing of imaging data here
Post Reply
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

View simultaneously external mask on top of original image

Post by user-6033 »

Hi,

We uses segmentation/processing/analysis etc based on your example with external mask. The mask itself is an independent ZenImage with a specific color and a specific name of the channel. Is there an easy way to overlay the mask on top of the original image so the color of the mask can be seen as a pattern on the original image? I guess I can construct a third image by copying the pixel values from both imgaes with conditions on the masking coordinates but I am convinced it should be something very simple which I do not see yet...

Best regards
Fredrik Olsson
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello Fredrik Olsson,

please try the AddChannel function to combine the original Image with the mask image.
Maybe you have to adjust the channel color.

The AnalyseToImage function (offered only in the macro library) can be used to label Analysis results with gray-values or colors.

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: ZEN23 - Show analysis results as burned in annotations
## Required files:cells_blue_red.czias, cells1.czi
##
## LOAD IMAGE, LOAD IMAGE ANALYSIS SETTING,
## SHOW ANALYSIS RESULTS AS BURNED IN ANNOTATIONS
## 
#######################################################
##
##
## Import library
from System.IO import File, Directory, Path
##
## Remove all open documents
Zen.Application.Documents.RemoveAll()
##
## Check existency of image analysis setting
doc = Zen.Application.Environment.GetFolderPath(ZenSpecialFolder.WorkgroupDocuments)
measPath = Path.Combine(doc,'Image Analysis Settings')
fileNames = []
itype = '*.czias'
iasName = 'cells_blue_red'
files = Directory.GetFiles(measPath,itype)
name = Path.Combine(measPath,iasName + '.czias')
sourcePath = Path.Combine('C:\\OAD\\Input\\CZI Images\\Micron Scaled','cells1.czi')
##
if File.Exists(name) == True: 
    ## Load analysis setting
    ias = ZenImageAnalysisSetting()
    ias.Load(iasName,ZenImageAnalysisSettingDirectory.Workgroup)
    ## Load image automatically
    image = Zen.Application.LoadImage(sourcePath, False)
    Zen.Application.Documents.Add(image)
    ##
    ## Create a 48bit color image with contours of objects of each class in class colors
    out7 =ZenImage()
    Zen.Analyzing.AnalyzeToImage(image,out7,ias,ZenAnalyzerLabelImageMode.Contour2ClassColor,ZenAnalyzerLabelImageInitMode.CopyFirstChannel,ZenPixelType.Bgr48)
    Zen.Application.Documents.Add(out7)
    ## get channelname of original image
    chName = image.Metadata.ChannelsText
    ## set channelname for output image
    out7.SetChannelName(0,chName)
    ## Clone display setting of original image
    dspClone = image.DisplaySetting.Clone()
    ## Apply setting to output image
    out7.SetDisplaySetting(dspClone,False)
    ##
    ## Create a 48bit color image with filled objects of each class in class color
    out8 =ZenImage()
    Zen.Analyzing.AnalyzeToImage(image,out8,ias,ZenAnalyzerLabelImageMode.RegionClassColor,ZenAnalyzerLabelImageInitMode.CopyFirstChannel,ZenPixelType.Bgr48)
    Zen.Application.Documents.Add(out8)
    ## set channelname for output image
    out8.SetChannelName(0,chName)
    ## Apply setting to output image
    out8.SetDisplaySetting(dspClone,False)
##
#######################################################
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Thank you, it works great!

I will still try something which is based on use of external mask since this is our default running mode.

I do think this is still an important missing issue of Zen, maybe for both Blue and Core that you can not efficiently extract threshold values from segmentation. In all "automatic mode" with a preknown (or automatically decided) threshold its no problem, or if thresholding is made for each image/segmentation then its great, but for cases where a user is setting up a scanning with an initial thresholding to be used for the sequential images then Zen could be improved. Our way to do it is to let the user make the thresholding and in a separete step write threshold value and afterwards rely on an external mask.

Best regards
Fredrik Olsson
Post Reply