Mirror/Invertion/Invert function not working with NaN

Discuss questions and projects related to processing of imaging data here
Post Reply
Olivier MESSE
Posts: 2
Joined: Thu Mar 18, 2021 2:26 pm

Mirror/Invertion/Invert function not working with NaN

Post by Olivier MESSE »

Hello,

I run into a problem when trying to invert an image along the z-axis.
Z-axis correspond to height and would need to invert it.

ZenCore has few possibility, including
Zen.Processing.Binary.Invert
Zen.Processing.Transformation.Geometric.Mirror
Zen.Processing.Arithematics.Inversion

but none are working.
I think that it stems from the fact that the dataset has NaN (non-measurements points).

This is very easy to solve, through a mask and apply the linear equation to the remaining data.
I just need to locate the Zarray on the image, but so far, I was not able to find where it is located.

I just need to create a mask to exclude the NaN and then create linear equation, with a = -1 and b=min(Z)+max(Z)

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

Re: Mirror/Invertion/Invert function not working with NaN

Post by CarlZeissMicroscopy3 »

Hello Olivier MESSE,

did you try Mirror like

imageNew = Zen.Processing.Transformation.Geometric.Mirror(imageOld, ZenMirrorMode.FlipVertical, ZenThirdProcessingDimension.None, False)

because this works in my cases.
Olivier MESSE
Posts: 2
Joined: Thu Mar 18, 2021 2:26 pm

Re: Mirror/Invertion/Invert function not working with NaN

Post by Olivier MESSE »

I did mention in the previous post that I used this function - which also yielded the same error:
(Scripting error: This function cannot process images that may contain NaN pixel values)

although, in my case and unlike suggested, I used this

Code: Select all

Zen.Processing.Transformation.Geometric.Mirror(imageOld, ZenMirrorMode.Flip3rd, ZenThirdProcessingDimension.Z, False)
Indeed, I wish to mirror the data along the Z-axis, that is in the thirdProcessingDimension.
Irrespective, I also attempted to use the exact function you mentioned which yielded the same error.

Any additional suggestion is welcome.
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Mirror/Invertion/Invert function not working with NaN

Post by CarlZeissMicroscopy3 »

Hello Olivier MESSE,

this is not an easy one and I just can give some ideas:

You could do something like “Change Pixel Type” e.g. 16Bit to get rid of NaN but depending on the image data a Shift (Add) and Multiply is needed so that values are in an appropriate range.

Another approach could be to use CopyPixelFrom/ToArray and eliminate the NaN more or less manually. Makes only sense for small images and you have to handle bytes.

Sorry, but I just can offer ‘workarounds’ …
Post Reply