Ask Your Question
0

Normalize hist with Norm_L1 doens't work ?

asked 2014-04-05 04:27:25 -0600

yes123 gravatar image

I am using the normalize function with this params:

normalize(hist, hist, 255, NORM_L1);

This should mean that the sum of every values inside the mat should equal to = 255
But later if i sum all values i get another value

sum(hist) != 255

To fix this error I need to call the normalize function like this:

normalize(hist, hist, 255, 0, NORM_L1);

Now I get:

sum(hist) == 255

Is this an intended behavior ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-04-05 05:09:03 -0600

May be you misunderstand the normalize function (see more at opencv's normalize). In this case (normalize(hist, hist, 255, 0, NORM_L1);), the result is that hist will have max value as 255, min value as 0 and its norm (L1 type) is 255.

edit flag offensive delete link more

Comments

You are wrong. When NORM_L1 only the norm-1 is = 255, not the max value of the hist = 255

yes123 gravatar imageyes123 ( 2014-04-05 05:30:29 -0600 )edit

Yes, the max and min values are wrong, but the norm is correct, so you will have sum(abs(hist))==255. That means your result is the intended value.

tuannhtn gravatar imagetuannhtn ( 2014-04-05 06:06:08 -0600 )edit

Ok but with this: normalize(hist, hist, 255, NORM_L1); I don't get sum(abs(hist))==255

yes123 gravatar imageyes123 ( 2014-04-06 05:50:03 -0600 )edit

Because it is a wrong call to normalize function, not the syntax but the semantic. When you call normalize(hist, hist, 255, NORM_L1);, indeed the norm type is NORM_L2 as default value of the normalize function, and the alpha is 255, beta is 2 (NORM_L1 is 2) (see normalize prototype at http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?#normalize for more details). So if you want to get sum(abs(hist))==255, you must invoke normalize function as normalize(hist, hist, 255, 0, NORM_L1);.

tuannhtn gravatar imagetuannhtn ( 2014-04-06 08:24:35 -0600 )edit

Question Tools

Stats

Asked: 2014-04-05 04:27:25 -0600

Seen: 2,773 times

Last updated: Apr 05 '14