scholi / pySPM

Python library to handle Scanning Probe Microscopy Images. Can read nanoscan .xml data, Bruker AFM images, Nanonis SXM files as well as iontof images(ITA, ITM and ITS).
Apache License 2.0
58 stars 33 forks source link

Normalisation of images #5

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi Scholi,

Is it possible to normalise images, either by total count or by another image?

Thanks Mat

scholi commented 5 years ago

I don't understand the point to normalize an image. The colorscale is automatically stretch to fit the min/max value, so normalizing the values won't change the color that you see. This can be tuned by using the vmax argument in order to specify the upper range of the colormap which is useful to compare several images. So as an example if you have an image A and B you can show them as follow:

max_ = max(np.max(A.pixels), np.max(B.pixels))
A.show(vmax=max_)
B.show(vmax=max_)

Is it what you were asking?

EDIT: Otherwise you can access directly the values of the images with .pixels and do the normalization you like with it. You can then plot it with matplotlib as a normal array. Or do the following trick:

import copy
A_normalized = copy.deepcopy(A)
A_normalized.pixels = A_normalized.pixels / normalization_value
A_normalized.show(vmax=some_value_you_like)
ghost commented 5 years ago

Sorry I usually normalise images by total to remove any topography issues with the sample.

Thanks I will try your recommendation

scholi commented 5 years ago

For your info, you can retrieve the total number of counts and the primary ions shots of the ITA object X as follow:

X.get_value("Analysis.SICount")['float']
X.get_value("Analysis.PIShots")['float']