1

Well I'm trying to normalize some (infrared) thermography data, to display it later.

However I'm stuck at normalizing, I could of course do it by hand, but I wonder why the matplotlib code is not working, the python code is shown below:

import numpy as N
import matplotlib.colors as colors

test2 = N.array([100, 10, 95])
norm = colors.Normalize(0,100)
for pix in N.nditer(test2, op_flags=['readwrite']):
    val = (norm.process_value(pix)[0])
    print (val)

img = norm.process_value(test2)[0]
print(img)

Now I expect vals OR img to show the correct processed data. Depending on what matplotlib.colors.Normalize.process_value actually should get as argument.

But in any case: both functions do not normalize and just return the original function.. Not on the [0, 1] interval at all.

0

1 Answer 1

1

The documentation of Normalize might be a bit deceiving here: process_value is a function which is only used for preprocessing (and static). The actual usage is described with this sentence:

A class which, when called, can normalize data into the [0.0, 1.0] interval.

Thus the normalization happens when you call the class:

import numpy as N
import matplotlib.colors as colors

test2 = N.array([100, 10, 95])
norm = colors.Normalize(0,100)
for pix in N.nditer(test2, op_flags=['readwrite']):
    val = (norm(pix))
    print (val)

img = norm(test2)
print(img)

Output:

1.0
0.1
0.95
[ 1.    0.1   0.95]
Sign up to request clarification or add additional context in comments.

2 Comments

why do you put the call in parenthese?
I tried to change as little as possible from the code of the question. The brackets were there so I left them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.