gpt4 book ai didi

c++ - 如何从 ofxKinect 视频中去除像素噪声?

转载 作者:行者123 更新时间:2023-11-28 08:00:58 24 4
gpt4 key购买 nike

我正在寻找一些帮助来弄清楚如何从视频中去除一些低质量的像素噪声,我是通过开放框架从 xbox kinect 获得的。我正在针对图像的“移动”部分运行逻辑,以确定哪种颜色移动最多,并使用这些区域来检测这些像素移动的深度。我附上了一张照片,试图更好地解释我的问题。

http://imago.bryanmoyles.com/xxw80

当然我知道会要求提供代码,所以我会发布目前为止的所有内容,但我最想要的是使用 C++ 平滑照片中像素化区域的好算法

for(int y = 0; y < kinect.height; y += grid_size) {
for(int x = 0; x < kinect.width * 3; x += 3 * grid_size) {
unsigned int total_r = 0, total_b = 0, total_g = 0;

for(int r = 0; r < grid_size; r++) {
for(int c = 0; c < grid_size; c++) {
total_r += color_pixels[(y * kinect.width * 3 + r * kinect.width * 3) + (c * 3 + x + 0)];
total_b += color_pixels[(y * kinect.width * 3 + r * kinect.width * 3) + (c * 3 + x + 1)];
total_g += color_pixels[(y * kinect.width * 3 + r * kinect.width * 3) + (c * 3 + x + 2)];
}
}

unsigned char average_r = total_r / (grid_size * grid_size),
average_b = total_b / (grid_size * grid_size),
average_g = total_g / (grid_size * grid_size);

for(int r = 0; r < grid_size; r++) {
for(int c = 0; c < grid_size; c++) {
color_pixels[(y * kinect.width * 3 + r * kinect.width * 3) + (c * 3 + x + 0)] = average_r;
color_pixels[(y * kinect.width * 3 + r * kinect.width * 3) + (c * 3 + x + 1)] = average_b;
color_pixels[(y * kinect.width * 3 + r * kinect.width * 3) + (c * 3 + x + 2)] = average_g;
}
}
}
}

for(int y = 0; y < kinect.height; y++) {
for (int x = 0; x < kinect.width * 3; x += 3) {
int total_difference = abs(color_pixels[y * kinect.width * 3 + x + 0] - rgb[0])
+ abs(color_pixels[y * kinect.width * 3 + x + 1] - rgb[1])
+ abs(color_pixels[y * kinect.width * 3 + x + 2] - rgb[2]);

unsigned char defined_color;

if(total_difference < 40) {
defined_color = (unsigned char) 255;
} else {
defined_color = (unsigned char) 0;
}

color_pixels[y * kinect.width * 3 + x + 0] = defined_color;
color_pixels[y * kinect.width * 3 + x + 1] = defined_color;
color_pixels[y * kinect.width * 3 + x + 2] = defined_color;
}
}

再次重申,我的代码不是问题所在,我只是将其发布在这里,以便您了解我不是盲目询问。我真正需要的是关于如何平滑像素化图像的一些指导,这样我的平均值就不会因为质量差而逐帧困惑。

最佳答案

您可以使用 ofxOpenCV 插件中的一些方法处理来自相机的图像。在那里你会有模糊、不失真、侵 eclipse 等方法。它很容易设置,因为它已经是一个插件。查看应该与您的 openFrameworks 一起打包的 openCvExample。有关上述方法的更多信息,请查看 here .如果我正确理解你的问题,那么图像上的一点模糊就可以解决你的问题。

关于c++ - 如何从 ofxKinect 视频中去除像素噪声?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11480800/

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