Selecting regions
Many computer vision applications require to focus interest inside local regions of the images. In that case, it is a very useful user tool to select the desired regions of interest (ROI). In the drawRs
example, we show how to select, with the mouse, rectangular regions in the image to locally increase the contrast inside these regions (as shown in the following screenshot). For better control over region selection, we implement a click-and-drag behavior to reshape the rectangular boundary of each region.
For the sake of simplicity, only the code corresponding to the function callback for mouse events is shown, since the rest is quite similar in the previous examples. The code is as follows:
void cbMouse(int event, int x, int y, int flags, void* userdata) { static Point p1, p2; // Static vars hold values between calls static bool p2set = false; if (event == EVENT_LBUTTONDOWN) { // Left mouse button pressed...