back to iatexture

Function norm3sigma normalization

Synopse

The norm3sigma function performs a pre-processing method called mean+-3sigma.

  • g = norm3sigma(f,roi)
    • Output
      • g: output image
    • Input
      • f: ndarray: input image.
      • roi: the region of interest

Description

The norm3sigma function performs a pre-processing method called 3 sigma. It is equivalent to normalize the image into [mu-3sigma, mu+3sigma] range, where mu is the ROI mean and sigma the ROI standard deviation.

Function Code

01. import numpy as np
02. 
03. def norm3sigma(f,roi):
04. 
05.     aux = f[roi]
06.     mu = np.mean(aux)
07.     sigma = np.std(aux)
08. 
09.     lower = np.round(mu-3*sigma)
10.     upper = np.round(mu+3*sigma)
11.     MIN = f.min()
12.     MAX = f.max()
13.     result = 1.0*(f-MIN)*(upper-lower) / (MAX-MIN) + lower
14.     return result

Example

01. import ia636
02. from norm3sigma import norm3sigma
03. 
04. f = adreadgray('p/LesionMRI/EM/Iani Surian Batalini - 746587-5 - 32A/22.png')
05. roi = adreadgray('p/LesionMRI/EM/Iani Surian Batalini - 746587-5 - 32A/Peri_22_1.png')>0
06. adshow(f, 'original image')
07. 
08. print 'f.min(),f.max()',f.min(),f.max()
09. result = norm3sigma(f,roi)
10. print 'f.info',ia636.iaimginfo(f)
11. print 'result.info',ia636.iaimginfo(result)
12. adshow(result,'3sigma normalization result')
f.min(),f.max() 1 254
f.info <type 'numpy.ndarray'> (256, 256) uint8 1 254
result.info <type 'numpy.ndarray'> (256, 256) float64 11.000000 148.000000

original image

3sigma normalization result