How to imitate GIMP Image/Crop to content

Need imitate GIMP Image/Crop to content function using OpenCV library.
Result needed: no border crossing upper/lower and left/right corner.
Please find sample below:

GIMP 2.10.30

Code which might be close to what would I need is below:

Mat image = imread("somePath.bmp");
image(Rect(Point(0, 10), Point(10, 0))).copyTo(cropped_image);
imshow("cropped_image", cropped_image);

I can’t use it as I dont know rectangle size and my images always have different size,but have similar pattern


This topic was automatically closed after 5 days. New replies are no longer allowed.