I have a numpy array image with a shape (channels, height, width), how can I change it so that it has a shape (height, width, channels)?
(channels, height, width)
(height, width, channels)
I assume it will be faster to use the numpy built-in function.
np.rollaxis(array_name,0,3).shape
You can use transpose()to select the order of the axes. In this case, you want:
transpose()
array.transpose(1, 2, 0)
This creates a new view in the original array when possible (data will not be copied).
You can do:
import numpy as np newim = np.zeros((height, width, channels)) for x in xrange(channels): newim[:,:,x] = im[x,:,:]
Source: https://habr.com/ru/post/1588968/More articles:Digital Signature and Fingerprint CXF WSS4JOutInterceptor - javaIs there any way F # print type of expression? - f #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1588965/mapkey-listsetobjects-of-type-defined-by-key&usg=ALkJrhi4ksCJarueDZ6snWOa8w-jbmN4uwSPARK: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient - hadoopSpark Streaming - How to get the "key" in the function updateStateByKey - apache-sparkPython: '{:,}'. Format () Why does it work? - pythonautomatic installation of jdk7 using jenkins failed - javaКак перечислить весь объект в списке завершения GC? - garbage-collectionUIButton not allocated on border - iosКак не нарушать этот первичный ключ при синхронизации с Azure? - c#All Articles