2
$\begingroup$

In the data-sets like coco-text and total-text, the images are of different sizes (height*width). I'm using these data sets for text detection. I want to create a DNN model for this. So the input data should be of same size. If I resize these images to a fixed size, the annotations given in the data-set, that is the location of the text in the images, will be changed.

So, how do I solve this problem?

$\endgroup$

2 Answers 2

1
$\begingroup$

Find the largest height and width amongst all the images. Let us call it H and W respectively. It is true that you cannot resize the images, but say if you have an image of height h and width w where h < H, w < W. To the right of the image append W - w number of columns and at the bottom of the image append H - h number of rows having some constant value (0 is okay for grey-scale and B/W images and 0 for each of the channel in case of colour images).

In this way all the images will be of same size. Since you appending at the right and bottom of the image, the annotations will not lose its meaning in the transformed image in terms of the position and content of the text to recognised.

You could also try pixelRNN kind of ideas after you are done with DNN. RNN can handle variable length inputs and in your case it will be sequence of pixels. Here you don't need to append rows and columns to the image.

$\endgroup$
3
  • $\begingroup$ Me too thought this method. But I'm afraid that this might affect the accuracy of the network. Is that true? Correct me if I'm wrong. $\endgroup$ Commented Jun 28, 2018 at 6:46
  • $\begingroup$ You don't have much of a choice as of now frankly. Since your dataset is quite huge, the effect of padding will not affect the text recognition IMHO. $\endgroup$
    – varsh
    Commented Jun 28, 2018 at 10:02
  • $\begingroup$ You can upvote of accept this as answer if it solves your problem. Thanks! $\endgroup$
    – varsh
    Commented Jun 29, 2018 at 6:12
0
$\begingroup$

Finally, I found answer for the question. In the annotations, we have X min & max and Y min & max of bounding box. So take the width and height of bounding box and center of bounding box relative to the image.

For example, let the image dimension be 500*500, the bounding box co-ordinates be (200, 200) and (300, 300). So, the center of bounding box is (250, 250) and the height and width is 100. Now, make it relative to image size.

center=(250/500,250/500)=(.5,.5)
height=width=(100/500)=.2

If you rescale the image, with this encodings you can bring back the bounding box with new rescaled image. if you enlarge the image to 1000*1000 then,

center=(.5*1000,.5*1000)=(500,500)
height=width=(.2*1000)=200

Hope this helps someone.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .