0
$\begingroup$

I'm training deep learning network using images (to be exact - I'm solving semantic segmentation problem).

What's the proper order of resizing (I need to resize images to fixed width X height) and normalization (dividing by 255 value) of images in preprocessing?

Does it make more sense to do first resizing and then normalization? Or first normalization and then resizing?

$\endgroup$

2 Answers 2

1
$\begingroup$

Resize and then normalize, that's the only pipeline that makes sense.

If you resize after normalization, depending on the resize algorithm, you may end up with values that are outside of the normalized range.

$\endgroup$
0
$\begingroup$

I don't think there will be a huge difference... although it will depend on how small you resize. The resizing is doing some kind of reduction and/or necessary interpolation (depending on the implementation you use).

If you plan to use OpenCV, you can check out the description here.

The benefit of normalisation after resizing would be that fewer operations would be performed (dividing fewer numbers by 255.0) - meaning slightly faster, but that difference is totally negligible. We both already spent more time talking about this topic than you will probably ever get back from that saving ;)

Finally, you might want to just experiment: pick 5 images, try out both methods on all of them and plot them next to each other to see if there are any differing artefacts. You can also compute things like the mean and variance of the final pixel values of the images transformed one way versus images transformed the other way.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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