Can you rewrite my function to not use the resize function from scipy please?