Yolov5- Handling Long Image Samples : Splitting a long Image in multiple parts based on horizontal similar pixel value

Viewed 116

I'm currently working on Yolo v5- Object Detection for chart/graph/table detection. For the standard-sized image samples, the detection seem to work fine.

However, I also have some images which are very long(4692 x 424). I'm having a hard time with these samples as the model is unable to show any detection. But when split to standard sub samples the graphs/charts are detected.

Here is a LongImageSample

So I decided to create an algorithm to partition the Long Images in standard sub samples. The algorithm is supposed to make a split(cut) where the horizontal line is of similar pixel(considering gradient) value with no other-pixel(containing any objects) intervention.

code snippet for the above algo:

samepix = checksamepix(iw,ih,max_height,a4height,width,img) #func to check similar pixel value through a horizontal path at a height "ih"
  if samepix==True:
    print("Condition for similar pixel is True")
    s1 = img[:ih, :]
    s2 = img[ih:, :]
    print(s1.shape)
    print(s2.shape)
    cv2.imwrite("half1.jpg", s1)
    cv2.imwrite("half2.jpg", s2)

But the above algorithm has a huge time complexity due to the linear traversal of pixels.

Do you have any other algorithm or way to partition the long images?

Do you have any other idea to handle the very long image samples for Yolov5 Object detection?

OR

Please acknowledge me if we have a library that could help make the process easier or reduce the Time complexity.

For a better understanding, If you want the entire code for the above algorithm, do let me know!

0 Answers
Related