Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

matplotlib radial averaging

import numpy as np
import matplotlib.pyplot as plt
from skimage import data

# get some image
image = data.coins()
image = image[:,0:303]

# create array of radii
x,y = np.meshgrid(np.arange(image.shape[1]),np.arange(image.shape[0]))
R = np.sqrt(x**2+y**2)

# calculate the mean
f = lambda r : image[(R >= r-.5) & (R < r+.5)].mean()
r  = np.linspace(1,302,num=302)
mean = np.vectorize(f)(r)

# plot it
fig,ax=plt.subplots()
ax.plot(r,mean)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: flask files not updating 
Python :: ex: python 
Python :: pydub reproduce audiosegment 
Python :: a = np.array([0, 0, 0]) and a = np.array([[0, 0, 0]]) 
Python :: plot by hour of day pandas 
Python :: unbreakable box made of diamond 
Python :: pygame.k_kp_enter 
Python :: u00a0 
Python :: django pointfield value format for fixtures 
Python :: how to print the freq of each char by using dict in python 
Python :: code=H18 desc="Server Request Interrupted" django 
Python :: organize order columns dataframe 
Python :: Python Print Variable Using the String Formatting with the help of % character 
Python :: .comments.all order django 
Python :: min_max_scaler.fit_transform 
Python :: write in file python 
Python :: python regex replace point with underscore 
Python :: Lists and for loops 
Python :: python group groupe of 2 
Python :: python login to O365 
Python :: Multiple sub in single regex. 
Python :: qcut and cut function in python stack overflow 
Python :: recover dict from 0-d numpy array 
Python :: count each value in lsitp ython 
Python :: pyspark pivot max aggregation 
Python :: pandas turn counts into probability 
Python :: Random Remarks Example in python 
Python :: vars() python 
Python :: how to make a chrome extension in python 
Python :: read file bytes python 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =