From WolframAlpha NormL1 and NormL2:
Given a vector:

Norm L1 is the taxicab (or manhattan) distance (sum of absolute values):

while Norm L2 is the euclidean distance (square root of sum of squares):

The type of norm tells the BFMatcher how to compute the distances between every two features.
The NORM L1 is in general much faster to compute (mostly because you don't compute the square root). The NORM L2 is more accurate.
You can find a nice comparison here.
Answer from Miki on Stack OverflowDifference between cv2.NORM_L2 and cv2.NORM_L1 in opencv python - Stack Overflow
How do i normalize an image better? - Python - OpenCV
Slow speed using cv2.norm(img1,img2) with opencv > 4.2.0.34
c++ - using opencv norm function to get euclidean distance of two points - Stack Overflow
What is the difference between NORM_MINMAX and NORM_L2?
Can cv2.normalize() use a mask?
What does cv2.normalize() do?
Note that, sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ) is the same as saying sqrt( (a - b).x * (a - b).x + (a - b).y * (a - b).y ), so you can call cv::norm(a - b).
However, according to this (albeit old) link, performance is poor for single point pairs.
I just ran the test code on my machine. It generates 15,000 points and calculates the distance from each to the remaining points.
a : [0, 0] - b : [2.14748e+09, 2.14748e+09]
euclideanDist : 3.037e+09
distanceBtwPoints : 3.037e+09
cv::norm : 3.037e+09
max_distance euclideanDist : 3.02456e+09 time passed :0.165179
max_distance distanceBtwPoints : 3.02456e+09 time passed :0.259471
max_distance cv::norm : 3.02456e+09 time passed :0.26728
Surprising. The fastest code is
float euclideanDist(cv::Point2f& a, cv::Point2f& b)
{
cv::Point2f diff = a - b;
return cv::sqrt(diff.x*diff.x + diff.y*diff.y);
}
Using cv::norm(a - b) and the code below are nearly equal:
static double distanceBtwPoints(const cv::Point2f &a, const cv::Point2f &b)
{
double xDiff = a.x - b.x;
double yDiff = a.y - b.y;
return std::sqrt((xDiff * xDiff) + (yDiff * yDiff));
}
But that's evidently because of the casts to double. If left as float, distanceBtwPoints is as fast as eucledianDist.
As you can read in the doc, the norm() set of functions all operate on the generic InputArray datatype. So, from here, you can see that this can be either a cv::Mat or std::vector but certainly not cv::Point2f.
After checking in the sources (of 3.0, but I doubt it was different in 2.4 series), I see that that function has 9 overloads, but the only ones with cv::Point<> only have one argument.
So you will need to to convert your points to cv::Mat. This can be done easily, as there is a constructor for cv::Mat that takes a point as argument. So just do:
std::cout << cv::norm( cv::Mat(a), cv::Mat(b) ) << std::endl;
But as a side comment, I am not sure that this is the best solution: it implies additional memory allocation, and it is probably faster to compute the distance directly (i.e.: sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ). It seems harsh, but you can rely on the compiler to optimize that.
If you want to change the range to [0, 1], make sure the output data type is float.
image = cv2.imread("lenacolor512.tiff", cv2.IMREAD_COLOR) # uint8 image
norm_image = cv2.normalize(image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
The other answers normalize an image based on the entire image. But if your image has a predominant color (such as black), it will mask out the features that you're trying to enhance since it will not be as pronounced. To get around this limitation, we can normalize the image based on a subsection region of interest (ROI). Essentially we will normalize based on the section of the image that we want to enhance instead of equally treating each pixel with the same weight. Take for instance this earth image:
Input image -> Normalization based on entire image

If we want to enhance the clouds by normalizing based on the entire image, the result will not be very sharp and will be over saturated due to the black background. The features to enhance are lost. So to obtain a better result we can crop a ROI, normalize based on the ROI, and then apply the normalization back onto the original image. Say we crop the ROI highlighted in green:

This gives us this ROI

The idea is to calculate the mean and standard deviation of the ROI and then clip the frame based on the lower and upper range. In addition, we could use an offset to dynamically adjust the clip intensity. From here we normalize the original image to this new range. Here's the result:
Before -> After

Code
import cv2
import numpy as np
# Load image as grayscale and crop ROI
image = cv2.imread('1.png', 0)
x, y, w, h = 364, 633, 791, 273
ROI = image[y:y+h, x:x+w]
# Calculate mean and STD
mean, STD = cv2.meanStdDev(ROI)
# Clip frame to lower and upper STD
offset = 0.2
clipped = np.clip(image, mean - offset*STD, mean + offset*STD).astype(np.uint8)
# Normalize to range
result = cv2.normalize(clipped, clipped, 0, 255, norm_type=cv2.NORM_MINMAX)
cv2.imshow('image', image)
cv2.imshow('ROI', ROI)
cv2.imshow('result', result)
cv2.waitKey()
The difference between normalizing based on the entire image vs a specific section of the ROI can be visualized by applying a heatmap to the result. Notice the difference on how the clouds are defined.
Input image -> heatmap

Normalized on entire image -> heatmap

Normalized on ROI -> heatmap

Heatmap code
import matplotlib.pyplot as plt
import numpy as np
import cv2
image = cv2.imread('result.png', 0)
colormap = plt.get_cmap('inferno')
heatmap = (colormap(image) * 2**16).astype(np.uint16)[:,:,:3]
heatmap = cv2.cvtColor(heatmap, cv2.COLOR_RGB2BGR)
cv2.imshow('image', image)
cv2.imshow('heatmap', heatmap)
cv2.waitKey()
Note: The ROI bounding box coordinates were obtained using how to get ROI Bounding Box Coordinates without Guess & Check and heatmap code was from how to convert a grayscale image to heatmap image with Python OpenCV
When the normType is NORM_MINMAX, cv::normalize normalizes _src in such a way that the min value of dst is alpha and max value of dst is beta. cv::normalize does its magic using only scales and shifts (i.e. adding constants and multiplying by constants).
CV_8UC1 says how many channels dst has.
The documentation here is pretty clear: http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#normalize
There are several types of normalization in Opencv.
Try running samples in the Online OpenCV-Flow tool to better understand each type.
