本文整理汇总了Python中scipy.misc.face函数的典型用法代码示例。如果您正苦于以下问题:Python face函数的具体用法?Python face怎么用?Python face使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了face函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_method
def setup_method(self, method):
im = face(gray=True)
self.ascent_offset = np.array((256, 256))
s = hs.signals.Signal2D(np.zeros((10, 100, 100)))
self.scales = np.array((0.1, 0.3))
self.offsets = np.array((-2, -3))
izlp = []
for ax, offset, scale in zip(
s.axes_manager.signal_axes, self.offsets, self.scales):
ax.scale = scale
ax.offset = offset
izlp.append(ax.value2index(0))
self.izlp = izlp
self.ishifts = np.array([(0, 0), (4, 2), (1, 3), (-2, 2), (5, -2),
(2, 2), (5, 6), (-9, -9), (-9, -9), (-6, -9)])
self.new_offsets = self.offsets - self.ishifts.min(0) * self.scales
zlp_pos = self.ishifts + self.izlp
for i in range(10):
slices = self.ascent_offset - zlp_pos[i, ...]
s.data[i, ...] = im[slices[0]:slices[0] + 100,
slices[1]:slices[1] + 100]
self.signal = s
# How image should be after successfull alignment
smin = self.ishifts.min(0)
smax = self.ishifts.max(0)
offsets = self.ascent_offset + self.offsets / self.scales - smin
size = np.array((100, 100)) - (smax - smin)
self.aligned = im[int(offsets[0]):int(offsets[0] + size[0]),
int(offsets[1]):int(offsets[1] + size[1])]
开发者ID:mwalls,项目名称:hyperspy,代码行数:30,代码来源:test_2D_tools.py
示例2: _plot_default
def _plot_default(self):
# Create a GridContainer to hold all of our plots: 2 rows, 4 columns:
container = GridContainer(fill_padding=True,
bgcolor="lightgray", use_backbuffer=True,
shape=(2, 4))
arrangements = [('top left', 'h'),
('top right', 'h'),
('top left', 'v'),
('top right', 'v'),
('bottom left', 'h'),
('bottom right', 'h'),
('bottom left', 'v'),
('bottom right', 'v')]
orientation_name = {'h': 'horizontal', 'v': 'vertical'}
pd = ArrayPlotData(image=face())
# Plot some bessel functions and add the plots to our container
for origin, orientation in arrangements:
plot = Plot(pd, default_origin=origin, orientation=orientation)
plot.img_plot('image')
# Attach some tools to the plot
plot.tools.append(PanTool(plot))
zoom = ZoomTool(plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
title = '{0}, {1}'
plot.title = title.format(orientation_name[orientation],
origin.replace(' ', '-'))
# Add to the grid container
container.add(plot)
return container
开发者ID:enthought,项目名称:chaco,代码行数:35,代码来源:image_plot_origin_and_orientation.py
示例3: plotImage
def plotImage( sCells ):
iSize, jSize = sCells.shape
sMax = sCells.max()
print 'The maximum value is: ',sMax
ima = np.zeros( (iSize, jSize, 3), dtype=np.uint8)
for i in range(iSize):
for j in range(jSize):
val = int( sCells[i][j] / sMax * 255)
if ((val >= 254) or (val == 0)):
ima[i][j][0] = 255
else:
ima[i][j] = val
# if sCells[i][j]==sMax:
# print i,j
f = misc.face(gray=True)
plt.imshow(f)
plt.title("... !!! ...")
plt.show()
plt.imshow(sCells, cmap=plt.cm.gray )
plt.title("Raw image (no filter)")
plt.show()
plt.imshow(ima)
plt.title("O and >249 values set to 255 (red)")
plt.show()
开发者ID:grasseau,项目名称:test,代码行数:29,代码来源:test_coef.py
示例4: get_image
def get_image():
# Build Image
try:
filename = sys.argv[1]
image = ndimage.imread(filename, flatten=True).astype(np.float32)
except IndexError:
image = misc.face(gray=True).astype(np.float32)
return image
开发者ID:ContinuumIO,项目名称:numbapro-examples,代码行数:8,代码来源:convolve.py
示例5: process_image_02
def process_image_02():
img = misc.face()
plt.gray()
plt.axis('off') # removes the axis and the ticks
plt.imshow(img)
print(img.dtype)
print(img.shape)
print(img.max)
plt.show()
开发者ID:Near-River,项目名称:machine_learning,代码行数:10,代码来源:process_01.py
示例6: test_connect_regions
def test_connect_regions():
try:
face = sp.face(gray=True)
except AttributeError:
# Newer versions of scipy have face in misc
from scipy import misc
face = misc.face(gray=True)
for thr in (50, 150):
mask = face > thr
graph = img_to_graph(face, mask)
assert_equal(ndimage.label(mask)[1], connected_components(graph)[0])
开发者ID:0664j35t3r,项目名称:scikit-learn,代码行数:11,代码来源:test_image.py
示例7: initMaps
def initMaps(self,size=49,dim=2,file="data/dice.jpg",timeStop=0.2,constant=0,**kwargs):
self.timeStop = timeStop
try:
im = misc.imread(file)
except Exception as e:
print(e)
im = misc.face()
im = misc.imresize(im,(size,size))
gray = to_gray(im)
value = (gray/255-0.5)*2
self.input = ConstantMap("picture",size=size,value=value)
return [self.input]
开发者ID:bchappet,项目名称:dnfpy,代码行数:13,代码来源:constant.py
示例8: test_cli
def test_cli(self):
f = plt.figure(frameon=False)
ax = f.add_subplot(111)
plt.imshow(face(), cmap=plt.cm.gray)
ax.set_axis_off()
ax.autoscale_view(True, True, True)
f.savefig("test.png", bbox_inches='tight')
plt.close()
import os
os.system('magiceye_solver test.png')
assert os.path.exists("test-solution.png")
os.remove("test.png")
os.remove("test-solution.png")
开发者ID:thearn,项目名称:magiceye-solver,代码行数:14,代码来源:test_magiceye.py
示例9: test_connect_regions_with_grid
def test_connect_regions_with_grid():
try:
face = sp.face(gray=True)
except AttributeError:
# Newer versions of scipy have face in misc
from scipy import misc
face = misc.face(gray=True)
mask = face > 50
graph = grid_to_graph(*face.shape, mask=mask)
assert_equal(ndimage.label(mask)[1], connected_components(graph)[0])
mask = face > 150
graph = grid_to_graph(*face.shape, mask=mask, dtype=None)
assert_equal(ndimage.label(mask)[1], connected_components(graph)[0])
开发者ID:0664j35t3r,项目名称:scikit-learn,代码行数:14,代码来源:test_image.py
示例10: image
def image():
f = misc.face()
misc.imsave("face.png", f)
face = misc.imread("face.png")
print face.shape, face.dtype # 8-bit images (0-255)
face.tofile("face.raw")
face_from_raw = np.fromfile("face.raw", dtype=np.uint8)
face_from_raw.shape = (768, 1024, 3)
import matplotlib.pyplot as plt
plt.imshow(f) # plt.show()
开发者ID:I-am-Gabi,项目名称:stega_python,代码行数:14,代码来源:image.py
示例11: _downsampled_face
def _downsampled_face():
try:
face = sp.face(gray=True)
except AttributeError:
# Newer versions of scipy have face in misc
from scipy import misc
face = misc.face(gray=True)
face = face.astype(np.float32)
face = (face[::2, ::2] + face[1::2, ::2] + face[::2, 1::2]
+ face[1::2, 1::2])
face = (face[::2, ::2] + face[1::2, ::2] + face[::2, 1::2]
+ face[1::2, 1::2])
face = face.astype(np.float32)
face /= 16.0
return face
开发者ID:0664j35t3r,项目名称:scikit-learn,代码行数:15,代码来源:test_image.py
示例12: framing_lena
def framing_lena():
lena = misc.face()
plt.imshow(lena, cmap=plt.cm.gray)
plt.savefig('lena.png')
crop_lena = lena[30:-30, 30:-30]
plt.imshow(crop_lena)
plt.savefig('crop_lena.png')
y, x = np.ogrid[0:512, 0:512]
print(y.shape, x.shape)
centerx, centery = (256, 256)
mask = (((y - centery)/1.)**2 + ((x - centerx)/0.8)**2) > 230**2
lena[mask] = 0
plt.imshow(lena[30:-30, 30:-30], cmap=plt.cm.gray)
plt.savefig('lena_mask.png')
return
开发者ID:ddboline,项目名称:programming_tests,代码行数:17,代码来源:framing_lena.py
示例13: setUp
def setUp(self):
super(TestImageLoader, self).setUp()
self.current_dir = os.path.dirname(os.path.abspath(__file__))
self.tif_image_path = os.path.join(self.current_dir, "a_image.tif")
# Create image file
self.data_dir = tempfile.mkdtemp()
self.face = misc.face()
self.face_path = os.path.join(self.data_dir, "face.png")
misc.imsave(self.face_path, self.face)
self.face_copy_path = os.path.join(self.data_dir, "face_copy.png")
misc.imsave(self.face_copy_path, self.face)
# Create zip of image file
#self.zip_path = "/home/rbharath/misc/cells.zip"
self.zip_path = os.path.join(self.data_dir, "face.zip")
zipf = zipfile.ZipFile(self.zip_path, "w", zipfile.ZIP_DEFLATED)
zipf.write(self.face_path)
zipf.close()
# Create zip of multiple image files
self.multi_zip_path = os.path.join(self.data_dir, "multi_face.zip")
zipf = zipfile.ZipFile(self.multi_zip_path, "w", zipfile.ZIP_DEFLATED)
zipf.write(self.face_path)
zipf.write(self.face_copy_path)
zipf.close()
# Create zip of multiple image files, multiple_types
self.multitype_zip_path = os.path.join(self.data_dir, "multitype_face.zip")
zipf = zipfile.ZipFile(self.multitype_zip_path, "w", zipfile.ZIP_DEFLATED)
zipf.write(self.face_path)
zipf.write(self.tif_image_path)
zipf.close()
# Create image directory
self.image_dir = tempfile.mkdtemp()
face_path = os.path.join(self.image_dir, "face.png")
misc.imsave(face_path, self.face)
face_copy_path = os.path.join(self.image_dir, "face_copy.png")
misc.imsave(face_copy_path, self.face)
开发者ID:ktaneishi,项目名称:deepchem,代码行数:40,代码来源:test_image_loader.py
示例14: main
def main():
drone = ps_drone.Drone()
drone.reset()
i=0
while (True):
cap = misc.face()
number=validation.classify("test/snapshot_iter_21120.caffemodel", "test/deploy.prototxt", cap,
"test/mean.binaryproto", "test/labels.txt")
print number
time.sleep(0.5)
i=i+1
if i>10:
exit()
开发者ID:vitarico,项目名称:CaffeModul,代码行数:23,代码来源:rundrone.py
示例15: face
#!/usr/bin/env python
"""
Demonstrate matplotlib image operations
Copyright 2018 Zihan Chen
"""
import matplotlib.pyplot as plt
from scipy.misc import face
plt.close('all')
fig, (ax1, ax2) = plt.subplots(2,1)
# read image
img = plt.imread('mpl_basics.jpg')
ax1.imshow(img)
# gray scale images
img_gray = face(gray=True)
ax2.imshow(img_gray, cmap=plt.cm.bone)
# show images
plt.show()
开发者ID:zchen24,项目名称:tutorial,代码行数:26,代码来源:mpl_images.py
示例16: module
"""
Displaying a Racoon Face
========================
Small example to plot a racoon face.
"""
from scipy import misc
f = misc.face()
misc.imsave('face.png', f) # uses the Image module (PIL)
import matplotlib.pyplot as plt
plt.imshow(f)
plt.show()
开发者ID:Andor-Z,项目名称:scipy-lecture-notes-zh-CN,代码行数:14,代码来源:plot_face.py
示例17: test_face
def test_face():
assert_equal(face().shape, (768, 1024, 3))
开发者ID:AlgorithmFan,项目名称:scipy,代码行数:2,代码来源:test_common.py
示例18: lena
low-pass filter which damps out frequencies which are higher than the
user specified cutoff frequency. In this example the cutoff frequency
is set to 40.
'''
import numpy as np
from scipy.misc import face
from scipy.interpolate import NearestNDInterpolator
import matplotlib.pyplot as plt
from rbf.filter import filter
np.random.seed(4)
x = np.linspace(0.0,1.0,768)
y = np.linspace(1.0,0.0,768)
x,y = np.meshgrid(x,y)
points = np.array([x.flatten(),y.flatten()]).T
values = np.linalg.norm(face(),axis=2)[:,256:].flatten()
#values = lena().flatten().astype(float)
values /= 441.7 # normalize so that the max is 1.0
signal = NearestNDInterpolator(points,values)
# interpolate Lena onto new observation points and add noise
points_obs = np.random.normal(0.5,0.3,(100000,2))
#points_obs = rbf.halton.halton(50000,2)
u_obs = signal(points_obs) + np.random.normal(0.0,0.2,100000)
# find filtered solution
cutoff = 60.0
soln,_ = filter(points_obs,u_obs,cutoff=cutoff,n=20,samples=0)
# plot the observed and filtered results
fig,ax = plt.subplots(2,1,figsize=(6,10))
ax[0].set_aspect('equal')
开发者ID:treverhines,项目名称:RBF,代码行数:31,代码来源:filter.a.py
示例19:
from scipy import misc
img = misc.face()
print(type(img))
开发者ID:snowdj,项目名称:raspberry-pi-supercomputing,代码行数:5,代码来源:prog06.py
示例20: ascent
# -*- coding: utf-8 -*-
"""Linear_fourier_filter_exercise.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1KQlihNHOyF1_p6he0IWGrdA23wIfoUvA
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy.misc import ascent, face
# Change this to an image of your choosing!
#image = ascent() # Boring staircase
image = face().mean(axis=2) # Cute little friend face
image = (image - image.mean()) / image.std()
n_x, n_y = image.shape
plt.imshow(image, cmap='Greys_r')
from numpy.fft import fft2, ifft2, fftshift
image_ft = fftshift(fft2(image))
amp = image_ft.real
phase = np.arctan2(image_ft.imag, image_ft.real)
X,Y = np.meshgrid( np.linspace(-.5, .5, n_y), np.linspace(-.5,.5, n_x) )
k = (X**2 + Y**2)**.5
开发者ID:fraser-lab,项目名称:fraser-lab.github.io,代码行数:31,代码来源:linear_fourier_filter_exercise.py
注:本文中的scipy.misc.face函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论