2016-10-03 11 views
0

私は第2のモノビタとして接続されている空間光変調器(SLM)を使っています。 SLMは、8ビットのグレースケール画像を受信します。 私は現在、vispyを使用してSLMに画像を表示していますが、正しく表示されていれば海岸ではありません。 vispyを使用してグレースケールでイメージを表示する可能性はありますか?vispyを使ってグレースケールで画像を表示

私はthis postを参照してください(あなたが灰色にRGBからあなたの写真を変換することができhttp://vispy.readthedocs.io/en/stable/examples/basics/scene/image.html

からあなたの助けに感謝、と悪い英語

答えて

0

して申し訳ありませんが、このコード

import sys 
from vispy import scene 
from vispy import app 
import numpy as np 

canvas = scene.SceneCanvas(keys='interactive') 
canvas.size = 800, 600 
canvas.show() 

# Set up a viewbox to display the image with interactive pan/zoom 
view = canvas.central_widget.add_view() 

# Create the image 
img_data = *my image* 
image = scene.visuals.Image(img_data, parent=view.scene) 

# Set 2D camera (the camera will scale to the contents in the scene) 
view.camera = scene.PanZoomCamera(aspect=1) 

if __name__ == '__main__' and sys.flags.interactive == 0: 
    app.run() 

を使用して画像をDISPLY )、次に「グレー」カラーマップを使用します。

import sys 
from vispy import scene 
from vispy import app 
import numpy as np 
from vispy.io import load_data_file, read_png 

canvas = scene.SceneCanvas(keys='interactive') 
canvas.size = 800, 600 
canvas.show() 

# Set up a viewbox to display the image with interactive pan/zoom 
view = canvas.central_widget.add_view() 

# Define a function to tranform a picture to gray 
def rgb2gray(rgb): 
    return np.dot(rgb[...,:3], [0.299, 0.587, 0.114]) 

# Load the image 
img_data = read_png(load_data_file('mona_lisa/mona_lisa_sm.png')) 

# Apply transformation 
img_data = rgb2gray(img_data) 

# Image visual 
image = scene.visuals.Image(img_data, cmap='grays', parent=view.scene) 

# Set 2D camera (the camera will scale to the contents in the scene) 
view.camera = scene.PanZoomCamera(aspect=1) 
view.camera.set_range() 
view.camera.flip = (0, 1, 0) 

if __name__ == '__main__' and sys.flags.interactive == 0: 
    app.run() 
+0

ありがとうございました! – stanissse

関連する問題