
The above image shows a rectangular section taken from the original image with reduced resolution. The trick is that all images contain a quadrangle which spans around the licence plate and that is darker in colour, in order to keep the licence plate readable. The coordinates of its corner points are documented in an XML file which has the same name as the JPEG, i.e. there is always a pair of files: the JPEG and the measuring information.
I wonder whether there is a way to apply a contrast stretch only to the region of the quadrangle and another only to the outer region, in order to achieve an even brightness of the entire image.
I have to admit that this is a very specific problem, but the general question is whether there is a way to limit certain operations, say blurring, to a polygonial selection within the image. I think that nowadays we often have the situation that we have an image and a bunch of additional information that is either embedded in it or comes as a separate file. So I could think of a lot of problem statements that are related to this question.