QT-QImage和多线程问题

发布于 2024-09-06 03:20:44 字数 955 浏览 1 评论 0原文

大家好,

请参考图片: http://i48.tinypic.com/316qb78.jpg

我们正在开发一个应用程序来提取来自电子显微镜的 MRC 图像的细胞边缘。

MRC 文件格式存储体积像素数据 (http://en.wikipedia.org/wiki/Voxel),我们只需使用 3D 字符数组(char***)从 MRC 文件加载和存储数据(灰度值)。

如图所示,有 3 个查看器分别显示 XY、YZ 和 ZX 平面。 查看器顶部的滚动条用于沿轴更改图像切片。

这是当用户更改滚动条位置时我们执行的步骤。

1) 获取新的滚动条值。(this 是选定的切片)

2) 对于相关平面(YZ、XY 或 ZX), 生成 (char* slice;) 数组 通过读取 3D 字符来选择切片 数组(字符***)

3) 创建一个新的 QImage* (Format_RGB888)并设置像素值 通过读取“切片”(使用 img->setPixel(x,y,c);)

4) 这个新的 QImage* 被绘制在 PaintEvent() 方法。

我们将在单独的线程中执行“边缘检测”过程,因为它是一个密集的过程。在此过程中,我们需要在 QImage* 之上绘制检测到的曲线(像素集)。(作为一层)。这意味着我们需要在QT线程之外调用drawPoint()方法。

对于这种情况,使用 QImage 是最好的方法吗?

从另一个线程执行 QT 绘图方法的最佳方法是什么?

提前致谢,

Greetings all,

Please refer to image at :
http://i48.tinypic.com/316qb78.jpg

We are developing an application to extract cell edges from MRC images from electron microscope.

MRC file format stores volumetric pixel data (http://en.wikipedia.org/wiki/Voxel) and we simply use 3D char array(char***) to load and store data (gray scale values) from a MRC file.

As shown in the image,there are 3 viewers to display XY,YZ and ZX planes respectively.
Scrollbars on the top of the viewers use to change the image slice along an axis.

Here is the steps we do when user changes the scrollbar position.

1) get the new scrollbar value.(this
is the selected slice)

2) for the relavant plane (YZ,XY or
ZX), generate (char* slice;) array for
the selected slice by reading 3D char
array (char***)

3) Create a new QImage*
(Format_RGB888) and set pixel values
by reading 'slice' (using
img->setPixel(x,y,c);)

4) This new QImage* is painted in the
paintEvent() method.

We are going to execute "edge-detection" process in a seperate thread since it is an intensive process.During this process we need to draw detected curve (set of pixels) on top of above QImage*.(as a layer).This means we need to call drawPoint() methods outside the QT thread.

Is it the best wayto use QImage for this case?

What is the best way to execute QT drawing methods from another thread?

thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半透明的墙 2024-09-13 03:20:44

来自QImage的文档:

因为QImageQPaintDevice子类,所以QPainter可用于直接在图像上绘制。在 QImage 上使用 QPainter 时,可以在当前 GUI 线程之外的另一个线程中执行绘制。

只需在您的图像上创建一个 QPainter 并绘制您需要的内容即可。

From documentation of QImage:

Because QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto images. When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread.

Just create a QPainter on your image and draw what you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文