Ask Your Question
0

Help with normalising

asked 2015-11-26 22:17:00 -0600

Hi all, trying to get useful data out of my Flir Lepton thermal camera.

It's giving me an 80x60 array of numbers, which can range from 0 to 65536, but they're usually around the 8000-mark.

The default pylepton_overlay code just uses cv2.normalize to stretch everything based on the min and max samples in the image. But the normalisation obviously changes based o n what's in the image.

What I want to do is clip everything below 7000 and above 9000, and normalise 7000 -> 0 and 9000 -> 65536.

Clipping is easy:

cv2.max(image,7000,image)

cv2.min(image,9000,image)

Now how do I nromalise to only the range of 7000:9000?

So far the auto-min/max code is:

cv2.normalize(image,image,0,65536,cv2.NORM_MINMAX,-1) # it needs another ',mask' at the end, that's what I want to know the format of.

The docs page is rather unhelpfully scant, "If you want to only use the mask to calculate the norm or min-max but modify the whole array, you can use norm() and Mat::convertTo()."

Yes, that's exactly what I want to do. Use a mask of ranges 7000 to 9000 as the min-max and normalise the whole array. Can anyone help me out as to how/syntax please?

edit retag flag offensive close merge delete

Comments

1

I don't understand your problem. If you use the max() and min() functions like above, you end up with an array with values between 7000 and 9000. If then you call cv2.normalize(image, image, 0, 65536, cv2.NORM_MINMAX), the result is what you're expected, I think. The mask is optional, as the previous -1 (it indicated depth of destination matrix). If that is not working for you, please provide an example to better understand the problem

LorenaGdL gravatar imageLorenaGdL ( 2015-11-27 04:05:05 -0600 )edit

Sorry, I wasn't exactly clear. Yes, it works fine if I've got a range of 6500 to 10000, clip to 7000-9000 then normalise. The problem is for a dull flat background I've got a range of 7800-8000. Clipping does nothing obviously, then normalising sends 7800->0 and 8000->65536.

Dr Croubie gravatar imageDr Croubie ( 2015-11-27 04:12:09 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-27 04:47:34 -0600

LorenaGdL gravatar image

Clear now :) Your problem will be solved by using function convertTo():

double alpha = 65535.0 / (9000.0 - 7000.0);
double beta = -7000.0 * alpha;
image.convertTo(image, CV_16U, alpha, beta);

It's C++ but convertion to Python should be straightforward. If you wanna know more details about why, the answer in this post is very explanatory.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-26 22:15:38 -0600

Seen: 757 times

Last updated: Nov 26 '15