本文整理汇总了Python中reprep.Report.data_rgb方法的典型用法代码示例。如果您正苦于以下问题:Python Report.data_rgb方法的具体用法?Python Report.data_rgb怎么用?Python Report.data_rgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.data_rgb方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_report_delayed
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_rgb [as 别名]
def create_report_delayed(exp_id, delayed, description):
delays = numpy.array(sorted(delayed.keys()))
r = Report(exp_id)
r.text("description", description)
f = r.figure(cols=3)
# max and sum of correlation for each delay
# corr_max = []
corr_mean = []
for delay in delays:
data = delayed[delay]
a = data["action_image_correlation"]
id = "delay%d" % delay
# rr = r.node('delay%d' % delay)
r.data(id, a).data_rgb("retina", add_reflines(posneg(values2retina(a))))
corr_mean.append(numpy.abs(a).mean())
caption = "delay: %d (max: %.3f, sum: %f)" % (delay, numpy.abs(a).max(), numpy.abs(a).sum())
f.sub(id, caption=caption)
timestamp2ms = lambda x: x * (1.0 / 60) * 1000
peak = numpy.argmax(corr_mean)
peak_ms = timestamp2ms(delays[peak])
with r.data_pylab("mean") as pylab:
T = timestamp2ms(delays)
pylab.plot(T, corr_mean, "o-")
pylab.ylabel("mean correlation field")
pylab.xlabel("delay (ms) ")
a = pylab.axis()
pylab.plot([0, 0], [a[2], a[3]], "k-")
y = a[2] + (a[3] - a[2]) * 0.1
pylab.text(+5, y, "causal", horizontalalignment="left")
pylab.text(-5, y, "non causal", horizontalalignment="right")
pylab.plot([peak_ms, peak_ms], [a[2], max(corr_mean)], "b--")
y = a[2] + (a[3] - a[2]) * 0.2
pylab.text(peak_ms + 10, y, "%d ms" % peak_ms, horizontalalignment="left")
f = r.figure("stats")
f.sub("mean")
a = delayed[int(delays[peak])]["action_image_correlation"]
r.data_rgb("best_delay", add_reflines(posneg(values2retina(a))))
return r
示例2: creation_suite
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_rgb [as 别名]
def creation_suite(fid, f): # @UnusedVariable
shape = [50, 50]
D = diffeomorphism_from_function(shape, f)
from reprep import Report
name = f.__name__
r = Report(name)
fig = r.figure()
M = 1
n1 = 10
n2 = 100
bx = [-.99, +.99] # depends on fmod
by = bx
params = dict(figsize=(3, 3))
def common_settings(pylab):
pylab.axis('equal')
pylab.axis((-M, M, -M, M))
turn_all_axes_off(pylab)
with fig.plot('grid1', **params) as pylab:
curved = CurvedPylab(pylab, f)
plot_grid(curved, n1=n1, n2=n2, bx=bx, by=by, hcol='k-', vcol='k-')
common_settings(pylab)
with fig.plot('grid2', caption="different colors", **params) as pylab:
plot_grid(curved, n1=n1, n2=n2, bx=bx, by=by, hcol='r-', vcol='b-')
common_settings(pylab)
with fig.plot('grid3', caption="smiley", **params) as pylab:
plot_grid(curved, n1=n1, n2=n2, bx=bx, by=by, hcol='r-', vcol='b-')
common_settings(pylab)
plot_smiley(curved)
with fig.plot('grid4', caption="smiley", **params) as pylab:
plot_grid(curved, n1=n1, n2=n2, bx=bx, by=by, hcol='k-', vcol='k-')
common_settings(pylab)
plot_smiley(curved, '0.5')
rgb = diffeomorphism_to_rgb(D)
r.data_rgb('diffeomorphism_rgb', rgb).add_to(fig)
filename = 'out/diffeo_creation_suite/%s.html' % name
print('Writing to %r.' % filename)
r.to_html(filename)
示例3: group_turnogram
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_rgb [as 别名]
def group_turnogram(group, configuration, saccades, #@UnusedVariable
image_width=250, zoom=8):
r = Report()
attach_description(r, description.format(width=image_width))
num_saccades = 0
num_samples = 0
signs = []
for sample, saccades_for_sample in iterate_over_samples(saccades): #@UnusedVariable
num_samples += 1
num_saccades += len(saccades_for_sample)
signs.append(saccades_for_sample['sign'])
colors = {-1: [0, 0, 255, 255], 1: [255, 0, 0, 255]}
bgcolor = [240, 240, 240, 240]
chunks = []
for i in range(num_samples):
sign = signs[i]
num_lines = int(numpy.ceil(len(sign) * 1.0 / image_width))
num_lines *= 2
chunk = numpy.ndarray(shape=(num_lines, image_width, 4) , dtype='uint8')
# white transparent
chunk[:, :, :] = bgcolor
for k in range(len(sign)):
x = k % image_width
y = ((k - x) / image_width) * 2
chunk[y, x, :] = colors[sign[k]]
chunks.append(chunk)
# add empty chunk
chunk = numpy.ndarray((2, image_width, 4), dtype='uint8')
chunk[:, :, :] = bgcolor
chunks.append(chunk)
img = numpy.vstack(chunks)
img_zoomed = zoom_rgb(img, zoom)
r.data_rgb('turnogram', img_zoomed)
return r
示例4: estimation
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_rgb [as 别名]
def estimation(fid, f): # @UnusedVariable
shape = [50, 50]
diffeo = diffeomorphism_from_function(shape, f)
K = 50
epsilon = 1
de = DiffeomorphismEstimator([0.2, 0.2], MATCH_CONTINUOUS)
for y0, y1 in generate_input(shape, K, diffeo, epsilon=epsilon):
de.update(y0, y1)
diff2d = de.summarize()
diffeo_learned = diff2d.d
from reprep import Report
name = f.__name__
r = Report(name)
fig = r.figure(cols=4)
diffeo_learned_rgb = diffeomorphism_to_rgb_cont(diffeo_learned)
diffeo_rgb = diffeomorphism_to_rgb_cont(diffeo)
r.data_rgb('diffeo_rgb', diffeo_rgb).add_to(fig)
r.data_rgb('diffeo_learned_rgb', diffeo_learned_rgb).add_to(fig)
L = r.data('diffeo_learned_uncertainty', diff2d.variance)
L.display('scale').add_to(fig, caption='uncertainty')
r.data('last_y0', y0).display('scale').add_to(fig, caption='last y0')
r.data('last_y1', y1).display('scale').add_to(fig, caption='last y1')
cs = [(0, 25), (10, 25), (25, 25), (25, 5)]
for c in cs:
M25 = de.get_similarity(c)
r.data('cell-%s-%s' % c, M25).display('scale').add_to(fig,
caption='Example similarity field')
filename = 'out/diffeo_estimation_suite/%s.html' % name
print('Writing to %r.' % filename)
r.to_html(filename)
示例5: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_rgb [as 别名]
def main():
cp = ClientProcess()
cp.config_stimulus_xml(example_stim_xml)
position = [0.5, 0.5, 0.5]
linear_velocity_body = [0, 0, 0]
angular_velocity_body = [0, 0, 0]
r = Report('am-I-crazy-test')
f = r.figure('varying theta', shape=(3, 3))
f2 = r.figure('varying x', shape=(3, 3))
f3 = r.figure('varying y', shape=(3, 3))
desc = lambda position, theta: 'At x: %.2f, y: %.2f, z: %.2f, theta: %d deg' % \
(position[0], position[1], position[2], numpy.degrees(theta))
idm = lambda position, theta, t: "%s-x:%.2f,y:%.2f,z:%.2f,th:%.3f" % (t, position[0], position[1], position[2], theta)
for theta in numpy.linspace(0, 2 * numpy.pi, 16):
position = [0.5, 0.5, 0.5]
attitude = rotz(theta)
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
lum = res['luminance']
id = idm(position, theta, 'theta')
r.data_rgb(id, plot_luminance(lum))
f.sub(id, desc(position, theta))
for x in numpy.linspace(0, 1, 20):
position = [x, 0, 0.1]
theta = 0
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
id = idm(position, theta, 'x')
r.data_rgb(id, plot_luminance(res['luminance']))
f2.sub(id, desc(position, theta))
for y in numpy.linspace(0, 1, 20):
position = [0, y, 0.1]
theta = 0
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
id = idm(position, theta, 'y')
r.data_rgb(id, plot_luminance(res['luminance']))
f3.sub(id, desc(position, theta))
filename = 'demo_pipe_rotation_experimenting.html'
print "Writing to %s" % filename
r.to_html(filename)
cp.close()
示例6: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_rgb [as 别名]
def main():
sigma_deg = 6
kernel1 = get_contrast_kernel(sigma_deg=sigma_deg, eyes_interact=True)
kernel2 = get_contrast_kernel(sigma_deg=sigma_deg, eyes_interact=False) # better
kernel1 = kernel1.astype('float32')
kernel2 = kernel2.astype('float32')
meany = Expectation()
ex1 = Expectation()
ex2 = Expectation()
cp = ClientProcess()
cp.config_use_white_arena()
cp.config_stimulus_xml(example_stim_xml)
#position = [0.15, 0.5, 0.25]
position = [0.35, 0.5, 0.25]
linear_velocity_body = [0, 0, 0]
angular_velocity_body = [0, 0, 0]
#from flydra_render.contrast import intrinsic_contrast
from fast_contrast import intrinsic_contrast #@UnresolvedImport
N = 360
pb = progress_bar('Computing contrast', N)
orientation = numpy.linspace(0, 2 * numpy.pi, N)
for i, theta in enumerate(orientation):
attitude = rotz(theta)
pb.update(i)
res = cp.render(position, attitude,
linear_velocity_body, angular_velocity_body)
y = numpy.array(res['luminance']).astype('float32')
meany.update(y)
#y = numpy.random.rand(1398)
c1 = intrinsic_contrast(y, kernel1)
c2 = intrinsic_contrast(y, kernel2)
ex1.update(c1)
ex2.update(c2)
r = Report()
r.data_rgb('meany', scale(values2retina(meany.get_value())))
r.data_rgb('mean1', plot_contrast(ex1.get_value()))
r.data_rgb('mean2', plot_contrast(ex2.get_value()))
r.data_rgb('one-y', (plot_luminance(y)))
r.data_rgb('one-c1', plot_contrast(c1))
r.data_rgb('one-c2', plot_contrast(c2))
r.data_rgb('kernel', scale(values2retina(kernel2[100, :])))
f = r.figure(shape=(2, 3))
f.sub('one-y', 'One random image')
f.sub('one-c1', 'Contrast of random image')
f.sub('one-c2', 'Contrast of random image')
f.sub('meany', 'Mean luminance')
f.sub('mean1', 'Mean over %s samples' % N)
f.sub('mean2', 'Mean over %s samples' % N)
f.sub('kernel')
filename = 'compute_contrast_demo.html'
print("Writing on %s" % filename)
r.to_html(filename)