Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

np.apply_along_axis third dimension python

In [131]: A = np.random.randint(0,255,(512,512,3)) # 512x512 colored image

In [132]: def org_app(A):
     ...:     out = np.zeros(A.shape)     
     ...:     for i in range(A.shape[0]):
     ...:         for j in range(A.shape[1]):
     ...:             out[i,j] = chromaticity(A[i,j])
     ...:     return out
     ...: 

In [133]: %timeit org_app(A)
1 loop, best of 3: 5.99 s per loop

In [134]: %timeit np.apply_along_axis(chromaticity, 2, A) #@hpaulj's soln
1 loop, best of 3: 9.68 s per loop

In [135]: %timeit np.log(A/np.power(np.sum(A,2,keepdims=True),1/3))
10 loops, best of 3: 90.8 ms per loop
Comment

PREVIOUS NEXT
Code Example
Python :: how to discover which index labels are in other 
Python :: controlliing a fill pattern in matplotlib 
Python :: repalce na with mean per group 
Python :: turn off slip in frozen lake openai gym 
Python :: how to use wbtools in python 
Python :: formula e xiaomi 
Python :: sumif in python on a column and create new column 
Python :: how to change the type of a values in list from str to object python 
Python :: get queryset 
Python :: hello world in dip 
Python :: crear ondas segun musica python 
Python :: django filter word count greater than 
Python :: Rewrite the equation shown in Figure 2.4 as a Python expression and get the result of the equation: Pay special attention to the order of operations. 
Python :: add sign to y axis values python 
Python :: how to select the shortest item in a python list 
Python :: fibonacci sequence python 2.7 
Python :: how to create fibonacci sequence in python 
Python :: api view wrapper django 
Python :: python selenium for desktop application 
Python :: test if instance in queryset django 
Python :: cross-validation sklearn image classification 
Python :: python seperate int into digit array 
Python :: python import shelve 
Python :: "opencv write video" 
Python :: diccionario 
Python :: # get documentation for module in terminal 
Python :: pairplot hide original legend 
Python :: how to limit variable godot 
Python :: html in nested structure 
Python :: Example of Python Strings with indexing 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =