你能为QCustomPlots ColorMap函数分配3个通道的图像数据吗?

时间:2022-08-12 18:45:44

I'm working on a program for image processing. At the present stage I split a CV_64FC3 into 3 colour channels, RGB, then use this as the data for a QCPColorMap.

我正在开发一个图像处理程序。在现阶段,我将CV_64FC3分成3个颜色通道RGB,然后将其用作QCPColorMap的数据。

The implementation is like this:

实现是这样的:

for(int col = 0; col < image.cols; ++col) {
    for(int row = 0; row < image.rows; row++) {
          colorMap->data()->setCell(row,col,rotated_matrix.at<double>(row,col));
    }
 }

Where rotated_matrix is a CV_64FC1 cv::Mat. This works fine and displays the colour map accordingly.

其中rotate_matrix是CV_64FC1 cv :: Mat。这很好,并相应地显示颜色图。

My question is can I pass through a 3 channel cv::Mat (CV_64FC3) and assign this to the data points in the QCPColorMap?

我的问题是我可以通过3通道cv :: Mat(CV_64FC3)并将其分配给QCPColorMap中的数据点吗?

I've had a look at the documentation and as far as I can see the only variables that colorMap->data()->setCell or colorMap->data()->setData can accept are keyIndex, valueIndex, z which represent essentially x coordinate, y coordinate and then the colour value itself.

我已经看了一下文档,据我所知,colorMap-> data() - > setCell或colorMap-> data() - > setData可以接受的唯一变量是keyIndex,valueIndex,z x坐标,y坐标,然后是颜色值本身。

I can't seem to find a way to modify the number of channels/layers in the image to assign.

我似乎无法找到一种方法来修改要分配的图像中的通道/图层数量。

Am I missing something here?

我在这里错过了什么吗?

Cheers Mitch

1 个解决方案

#1


0  

Here's a somewhat painful way: put multiple instances of QPColorMap over each other and use the alpha channel to toggle off selected ones. I suppose one could sub-class QPColorMap and access QRgb that way, but that would be even harder.

这是一种有点痛苦的方法:将多个QPColorMap实例相互叠加,并使用alpha通道切换选定的实例。我想可以通过这种方式对QPColorMap进行子类化并访问QRgb,但这样会更难。

This does seems like a target for modification in QCustomPlot. My sample application: show a grayscale image (e.g., a brain) with a color overlay indicating either a region of interest or an "activated" or somehow abnormal area. For this one needs access to the RBG fields.

这似乎是QCustomPlot中修改的目标。我的示例应用:显示具有颜色叠加的灰度图像(例如,大脑),该颜色叠加指示感兴趣的区域或“激活的”或某种程度上的异常区域。为此,需要访问RBG字段。

#1


0  

Here's a somewhat painful way: put multiple instances of QPColorMap over each other and use the alpha channel to toggle off selected ones. I suppose one could sub-class QPColorMap and access QRgb that way, but that would be even harder.

这是一种有点痛苦的方法:将多个QPColorMap实例相互叠加,并使用alpha通道切换选定的实例。我想可以通过这种方式对QPColorMap进行子类化并访问QRgb,但这样会更难。

This does seems like a target for modification in QCustomPlot. My sample application: show a grayscale image (e.g., a brain) with a color overlay indicating either a region of interest or an "activated" or somehow abnormal area. For this one needs access to the RBG fields.

这似乎是QCustomPlot中修改的目标。我的示例应用:显示具有颜色叠加的灰度图像(例如,大脑),该颜色叠加指示感兴趣的区域或“激活的”或某种程度上的异常区域。为此,需要访问RBG字段。