How to crop the image as wide as possible? [closed]
I want to be able to crop any image with the smallest bounding box possible. Example:
I have the "a" image and want to crop the image with the smallest rectangle that encompasses my image.
well you need to define the bounding box / region of interest as small as possible. If this is not what you want to know - rephrase your question ^^
Yes, that's what I want. But I do not know how. I have already found this boungingBox function but I do not know how to implement it in a code. I'm new to Opencv and C ++. Could you show me how it would be done?
Can you post the critical code where you get the bounding box? Also its good to give context - what methods calls are you using for bbox detection etc. Are you using contours?
If you mark the bounding box with rectangle and then use imshow - is the result sufficient? If yes it only about extracting - if not - you need to work on the detection,
Yes, I'm using outlines. What I thought and was trying to do was: 1)I open the image. 2)I use the "canny" function to get the outlines. 3)I draw the contours with "drawcontours".
From there I would use the boundBox to find the minimum rectangle. But I saw that I would have to turn it to get this.
I saw this in:link text In the 7b step.
But in example, he use points, but i have contours.. i don't now how to do.
I have this example too: link text
But he have an circle and when i try cut this parte of code(circle) i don't now what to do.
link text
the exemple of the step 7b.
Hmm i dont get your problem - i suggest: Study once again this examplehttps://docs.opencv.org/2.4/doc/tutor...
In the code you see the following line:
And later
Which will draw a rectangle - but you can also these cooridates to extract the region you want to extract. Like here https://stackoverflow.com/questions/8...
Btw the link i copied from you is from opencv 2.4 and we are in 2018 :-)