How to find largest axis aligned rectangle inside a contour
Hello,
I want to find largest axis aligned rectangle inside a contour? I've found the contour (findContours) and approximated it (approxPolyDP). Now I need to find biggest axis aligned rectangle that fits inside the contour's approximated polygon.
UPDATE: The contour is approximately a rectangle. The problem I want to solve it to remove black areas around a stitched panoramic image.
I tried:
Approach #1 This approach fits my needs but I don't like the heuristic.
Approach #2 This approach assumes that the image has no black areas to the top and to the left of the image which is not acceptable in my case.
Any help will be appreciated. Thanks!
This is a quite difficult task. http://citeseerx.ist.psu.edu/viewdoc/...
Could be a bit more specific? What do you want to achieve? Is your polygon convex (of even approximately a rectangle)? What is your needed accuracy?
@FooBar Thanks for the link. I updated the question.
@MrVincenzo what you do not like in the first approach?
@theodore It is good only for some usecases and not for all. Consider the case where an image has a black area in it's interior near one of the boundaries. In this case, the largest rectangle will be reduced unnecessarily.