0

how do i remove the text from manga page i already crop it using ROI and i want to replace it with new text using cv2.putText()

this is the sample of the image

sample image

I used a trick to make cv2.inpaint more accurate to remove the text, but I just realized that these masks are not connected to each other to find the accurate center x, y, w, h of the single ROI of this image. masking

should i calculate the middle x,y coordinate using this function from original size or any advice to make it more accurate to put the new text in the middle of the w and h then wrap it ?

def midpoint(x1,y1,x2,y2): 
  x_mid = int((x1+x2)/2) 
  y_mid = int((y1+y2)/2)
  return (x_mid,y_mid) 
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Xander
  • 11
  • 1
  • 4
  • 1
    Just replace your whole crop section with a white image and draw new text on it. No point in trying to find each row of text and white over it. – fmw42 Aug 20 '23 at 17:35

1 Answers1

0

If I understand you correctly you already were able to remove the text with your approach and the center of each of each row. So you can get the center of all your "textboxes" like in your "midpoint" function (you have more than 2 coordinates so you need to expand it, like ((x1+x2+..xn)/n).) Then you can put some text in your calculated center, like explained here.

fpl
  • 1
  • 2
  • what have you tried so far ? the question needs sufficient code for a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) – D.L Aug 22 '23 at 10:45
  • i inpainted the text to remove the text after that i need find the center of the image to put the translatation text into the image and then wrap it to make sure it's fit but no, because every ROI i just got only containt the text not the right size of bubble speech this is the main core i face it right now,that's why **find the center of image to put traslation text** it's hard – Xander Aug 23 '23 at 11:37