gpt4 book ai didi

matlab - 3 channel 深度图像1 channel

转载 作者:太空宇宙 更新时间:2023-11-03 22:55:50 27 4
gpt4 key购买 nike

我使用 Kinect v2 录制了一个深度视频,当我使用 MATLAB 提取图像时,每个 image是3 channel 。通常我看到的图像只有 1 个 channel 。请任何人告诉我如何将这个 3 channel 图像变成 1 channel ?

深度部分的代码如下:

IplImage depth = new IplImage(512, 424, BitDepth.U16, 1);
CvVideoWriter DepthWriter;
Width = sensor.DepthFrameSource.FrameDescription.Width;
DHeight = sensor.DepthFrameSource.FrameDescription.Height;
WbDepth = new WriteableBitmap(DWidth, DHeight, 96, 96, PixelFormats.Gray16, null);
int depthshft = (int)SliderDepth.Value;
using (DepthFrame depthframe = frame.DepthFrameReference.AcquireFrame())
ushort* depthdata = (ushort*)depth.ImageData;
if (depthframe != null)
{
Depthdata = new ushort[DWidth * DHeight];
ushort[] Depthloc = new ushort[DWidth * DHeight];
depthframe.CopyFrameDataToArray(Depthdata);
for (int i = 0; i < DWidth * DHeight; i++)
{
Depthloc[i] = 0x1000;
}
colorspacePoint = new ColorSpacePoint[DWidth * DHeight];
depthspacePoint = new DepthSpacePoint[CWidth * CHeight];
sensor.CoordinateMapper.MapDepthFrameToColorSpace(Depthloc, colorspacePoint);
for (int y = 0; y < DHeight; y++)
{
for (int x = 0; x < DWidth; x++)
{
if (depthshft != 0)
{
Depthdata[y * DWidth + x] = (ushort)((Depthdata[y * DWidth + x]) << depthshft);
}

}
}
depth.CopyPixelData(Depthdata);
}
WbDepth.WritePixels(new Int32Rect(0, 0, DWidth, DHeight), Depthdata, strideDep, 0);
ImageDepth.Source = WbDepth;
if (depth != null && DepthWriter.FileName != null) Cv.WriteFrame(DepthWriter, depth);
Cv.ReleaseVideoWriter(DepthWriter);
if (CheckBox_saveD.IsChecked == true)
DepthWriter = new CvVideoWriter(string.Format("{1}\\Scene{0}_DepthRecord.avi", scene, TextBlock_saveloca.Text.ToString()), FourCC.Default, 30.0f, new CvSize(512, 424));
CheckBox_saveD.IsEnabled = false;
if (CheckBox_saveD.IsChecked == true) Cv.ReleaseVideoWriter(DepthWriter);

谢谢

最佳答案

到目前为止,每个人都建议您将(假定的)彩色图像转换为灰度图像。 我认为你不应该这样做。kinect 为您提供深度值的“1 channel ”图像。如果您有彩色(3 channel )深度图,则说明有问题。转换为灰度会使您失去深度信息

相反,首先尝试弄清楚为什么您的图像以灰度加载。来源是什么?读取图像时是否可以通过 Matlab 完成转换?然后你可以给它一些标志告诉它不要这样做吗?

关于matlab - 3 channel 深度图像1 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30734752/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com