opencv - How to deal with 8UC3 and 8UC4 simultaneously in android ndk -
Using my code below, my code is working fine with the brightness in the image
< Code> jint * _in = env- & gt; GetIntArrayElements (in, 0); Jint * _out = env- & gt; GetIntArrayElements (outside, 0); Mat MSRC (height, width, CV_8 UC4, (unsigned char *) _); Mat bgra (height, width, CV_8 UC4, (unsigned char *) _ out); Of vector & lt; Mat & gt; SChannels; Division (MSRC, sChannels); For (int i = 0; i & lt; sChannels.size (); i ++) {MAT channel = sChannels [i]; EqualizeHist (channel, channel); } Merge (sChannels, bgra); Env-> Releaseintheatrelease (in, _in, 0); Env-> Release Initrements (Out, _out, 0); Jint Retal; Int rate = 1; Retal = h int (retal); Return rate;
This image also works for me to convert to grayscale, but in this way:
Mat mSrc (height, width, CV_8UC4, ( Unsigned char *) _in); Mat gray (height, width, cv_ 8 UC1); Mat bgra (height, width, CV_8 UC4, (unsigned char *) _ out); CvtColor (MSRC, Gray, CV_BGRA2GRAY); CvtColor (Gray, bgra, CV_GRAY2BGRA);
But when I'm trying to use bilateralfilter
, which only works with 3 channels, how to deal with it? Because the Java bitmap accepts RGBA
format, and when I am in the
Mat mSrc (height, width, CV_8UC3, (unsigned char *) _) Change; Mat bgra (height, width, cv_ 8 UC3, (unsigned char *) _);
Anyhow, bilateral filter shows me the output, but what if I applied all these filters to an image? How can I handle this problem? Because there may be other algorithms that work with only 3 channels.
If you call CV_8UC3
to CV_8UC4
Required to:
cvtColor (src, dst, CV_BGR2BGRA);
Because it produces a 4-channel image (R, G, B, and Alpha)
Inverted,
CvtColor (src, DST, CV_BGRA2BGR); Convert
from CV_8UC4
to CV_8UC3
Comments
Post a Comment