Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

there's a couple of ways to do so:

  1. just change the flag: imdecode(vectordata, IMREAD_COLOR);
  2. or convert it later: cvtColor(mat,mat,COLOR_BGRA2BGR);

but those will just discard the alpha channel. to replace pixels, try like:

Mat channels[4];
split(mat, channels);
merge(channels,3,mat);
mat.setTo(Scalar::all(255), (channels[3]<255));

(though i doubt, that this will be faster, than your loop)

in general, try to avoid images with alpha, they were made to look good on a web-page, but are a bat fit for computer-vision