# Normalization for well known data sets like coco-text and total text data set

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 input data should be of same size. If I resize these images to a fixed size, annotations given in the data-set that is the location of the text in the images will be changed.

So how to proceed with these data-set? I'm new to machine learning and I didn't get answer for this anywhere. Thanks for the help.

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.

• 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. – Gokulakannan Jun 28 '18 at 6:46
• 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. – varsh Jun 28 '18 at 10:02
• You can upvote of accept this as answer if it solves your problem. Thanks! – varsh Jun 29 '18 at 6:12

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 Image dimension be 500*500. Bounding box co-ordinates be (200,200) and (300,300). So center of bounding box be (250,250) and height and width be 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 to someone like me!