unity3d - 将 Dicom 图像像素值转换为 Unity 颜色
问题描述
我使用 SimpleITK 在 Unity 中读取 Dicom 图像。我创建了一个 Unity Texture2D 列表来存储 Dicom 切片。我的问题是我们如何将像素值从 Dicom 图像转换为 Unity Color?
List<Texture2D> _imageListTexture = new List<Texture2D>();
for (int k = 0; k < depth; k++)
{
Texture2D _myTex = new Texture2D(width, height, TextureFormat.ARGB32, true);
for (int j = 0; j < height; j++)
{
for (int i = 0; i < width; i++)
{
int idx = i + width * (j + height * k);
float pixel = liverVoxels[idx]; //We have the pixel value
Color32 _col = new Color32(); //Unity has rgba but we have only one value
//What to do here?
_myTex.SetPixel(i, j, _col);
}
}
_myTex.Apply();
_imageListTexture.Add(_myTex);
}
解决方案
这很简单:
float pixel = liverVoxels[idx]; //We have the pixel value
Color32 _col = new Color32(pixel, pixel, pixel,255);
_myTex.SetPixel(i, j, _col);
推荐阅读
- javascript - Object.create() 使用
- python - 在 python 中启动键绑定
- ios - 未发送推送通知 quickblox
- java - CompletableFuture runAsync 与新线程
- solr - 使用 Solr 索引共享文件夹
- javascript - 单击正文而不是两个 div
- sql-server-2008 - 结合 3 个 sql 查询的结果来计算运行库存
- zend-framework3 - zend 框架 3 - 获取 sql 字符串
- entity-framework - 实体框架 - 跨链接表查询所有记录
- docker - Kubernetes 访问 Persistance 卷挂载外部