Count white pixels in each column in contours (with cv2.countNonZero()?)

In a picture i find two contours among each other which look like this:


I use cv.OTSU_THRESHOLD to find them with cv.findCountours() or cv.connectedComponentsWithStats() without a problem. I will use whatever is best for the actual problem.

Now i want to measure the height of each column for each of the contours, and display the minimum height, maximum height and maybe even the height every n pixel. I already use cv.minAreaRect and display it, but its still not as accurate as i would like it. I am also able to find pixel_per_mm_ratio with an ArUco Marker without problems. From theory, it cant be that hard…

I thought i can use cv.countNonZero() but i dont know how to apply this function for contours and for each column. I found some topics going in this direction but nothing helped me to the end. I even posted a topic here where i got great help but i couldnt do the really last step i guess. There you can even find some simplified code with connected components: Height of contour at different positions - #10 by digerid

Thanks for your help!