1 | initial version |
It seems the image you provide is with alpha channel, where as you said the white region is complete transparent(alpha = 0), so just do the following.
Load source with alpha, you should set flags = -1 on imread().
Now split image in to four channel.
Mat splitedBGRA[4];
split(src,splitedBGRA);
Note that OpenCV channel order is BGRA.
Now threshold alpha channel, you should use THRESH_BINARY_INV
.
See the result I got with the above algorithm.