Ask Your Question

Kolibri's profile - activity

2016-08-17 15:15:55 -0600 commented question Mat different channels

If you are reading them with imread without specifiers, they will always be 3 channel 8 bit images

Ah, that is good to know, thanks!

Once an image is loaded you can retrieve its type, which in turn can be compared to for example CV_8UC3 or CV_8UC4 to know how many channels there are.

This is exactly what I ended up doing :D

2016-08-16 22:01:20 -0600 asked a question Mat different channels

Hello everyone, newbie here.

I am trying to put the pixel values of one Mat into another via mat.put(x,y,values)

That does work, but only for Mats of the same type. When they are not, I get an error.

Provided data element number (4) should be multiple of the Mat channels count (3)

The solution to that problem would be to have the Mats share the same type by converting one of them (right?).

The problem with THAT is, that I need to explicitly state in the cvtColor - Method, which channel to convert (and how). But I do not know the exact channel on runtime, channels count should either be 3 or 4...

So, how do I convert one mat to the type of another mat dynamically? Any ideas?

Thank you very much.

With kind regards, David.