This does not solve the question, but is a collection of images you have posted yet:
- A cropped output (logo only partially visible at the top), some downsampling seems to be applied also (clear text, but zooming into the horizontal ruler reveals some artifacts), saved as JPEG with a high quality, a white border at the bottom (I added a green box to show it):
2. A downsampled image (you can recognize this by the artifacts of the text and the almost vanishing horizontal ruler (right click on the image to enlarge it, and of ). A large white border is added (I've added a green border such that you can see the white area). Zooming in e.g. at the dashes of the ruler shows strong artifacts from the JPEG compression, which impedes the further processing massively:
See the JPEG artifacts, zoomed by 800% - do you see the dark grey pixels and the different colors of the actuall dashes?
3. Another file with a yellow box - not explained how you have created it - same white border (again I added the grren border), artifacts, downsampled:
4. A contour graph, which was obviously build based on an image with JPEG artifacts - see the unclear tick marks at the horizontal ruler at the bottom. It is unlikely that any meaningful measurement can be done based on such images:
As soon as you explain, that type 1. is the used as input, a solution would be rather easy. In opposite to this starting with the noisy type 4. images is very demanding.
You exaplain: "The input are the jpgs images. They are not downsampled." Then why do you post downsampled JPEGs and not the real input? Why do you make the processing much harder (or impossible), by using lossy JPEGs as input?
I've worked with ultra-sound deviced repeatedly. In all cases the screen has been stored lossless as PNG, TIFF or GIF, to avoid the JPEG artifacts. The recognition of the actual data has been easy, because it was at well defined pixels positions. An automatic cropping is very easy also, when the positions are exactly defined.
"Why is it so difficult to understand my query?" Because your explanations do not match the posted examples, because you have a confused idea about cropping, because you do not answer questions for clarifications and ignore suggestions. This is your problem. Nobody but you suffers, if it is not solved. I only want to help you as I do in all other threads.