I am trying to learn a bit of deep learning playing with the Street View House Numbers data set. I have managed to recognize sequences of digits and I'd like now to train a CNN to localize digits and provide boxes coordinates. The problem is that I have the boxes coordinates related to the original image sizes which are always different.

I have to resize the images in order to have homogenous input for the NN but I don't know hot to transform the boxes coordinates coherently.


Since you are saying that you got box coordinates in the original image, why not reduce coordinates by exactly same scale.

For example a coordinate say $(100,100)$ in the image of say $(1024,1024)$ size when resized to say $(256,256)$ will be $(25,25)$ (assuming you didn't crop anything in the mean while), which is in general

$$(x_{new},y_{new}) = (\frac{x_{old}*l_{new}}{l_{old}},\frac{y_{old}*b_{new}}{b_{old}})$$ where $l$ is the length of the image, $b$ is the width.

In times of fractional answers after reduction make sure your bounding box covers a bigger area. For example, Y-coordinate for the left side of bounding box should be pushed towards the Y-axis while on the right should be pushed towards the ceil value like say you got $25.5$ by reducing, go to 25 when on the left side while $26$ when on right side of bounding box. Similarly up and down for $x's$.

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.