B
B
BitNeBolt2019-03-17 21:39:28
Python
BitNeBolt, 2019-03-17 21:39:28

How to divide all values ​​of an array by a number (numpy)?

There is a huge numpy array (image), and I need to divide each pixel value for each channel by 255. Running through the array takes too much time and space. Is there any simple (optimized) way to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2019-03-17
@BitNeBolt

import numpy as np
a = np.array([(255, 255, 255), (128, 128, 128), (255, 128, 255), (255, 255, 255)])
print(a / 255)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question