Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #2102
This pullrequest changes
During one of the stages of selective search, the image is rotated 45 degrees and gradients are computed along the X and Y directions in the rotated image. The gradient image is then rotated back to the original orientation and cropped to remove surrounding empty space, leaving it with the same shape as the original image. However, the implementation of the crop will specify an ROI with negative x or y values if the image's native aspect ratio is too high or too low (basically, if the image is far from square).
This is because the bounding box of the rotated image is strictly bigger than the original image if the original is sufficiently close to square; but if the original is too "skinny", the bounding box of its rotation will be less tall or wide than the original.
The fix is to threshold the x and y computed for the ROI at 0.
Note: while fixing this bug, I also discovered that parts of "narrow" gradient images were being clipped at their edges due to improper cropping, again due to the apparent assumption that the bounding box of the rotated image was always strictly bigger in both axes than the original image. This PR includes a fix for that as well.
Another note: Something seemed to go wrong with the previous PR, so I've created this new one.