Split BGR into 3 separate images
I have used a couple of CV_32FC3 for processing and wish to convert one of the channels of each into CV_8UC1. I tried this:
Mat imgMedR(157, 78, CV_16UC3) ;
Mat imgMedL(157, 78, CV_16UC3) ;
Mat imgFiltR(157, 78, CV_32FC3) ;
Mat imgFiltL(157, 78, CV_32FC3) ;
medianBlur(imgLocsL, imgMedL, KernSize); //imgLocsL & imgLocsR work fine without the snippet shown
Scharr(imgMedL,imgFiltL, CV_32F, 1,0);
medianBlur(imgLocsR, imgMedR, KernSize);
Scharr(imgMedR,imgFiltR, CV_32F, 1,0);
Mat imgL(157, 78, CV_32FC1);
Mat imgR(157, 78, CV_32FC1);
Mat imgBGR_R[3],imgBGR_L[3];
split(imgFiltR, imgBGR_R);
split(imgFiltL, imgBGR_L);
imgR = imgBGR_R[3] / 64.0f;
imgL = imgBGR_L[3] / 64.0f; //Valgrind says I have a segment fault here but not the line above.
//the error identified is imgR.convertTo(imgRight, CV_8U); imgL.convertTo(imgLeft, CV_8U);
The Valgrind err messagesa re Conditional jump or move depends on uninitialised value(s) Use of uninitialised value of size 8 and Invalid read of size 4
I confused. If imgLocsL and imgLocsR are OK, then the variables in the Mat at the offending line should have a valid value of type CV_32F.
If the error was after the converto, then I could save the image and look at it.
Anybody have any hints on how to troubleshoot this?
Thanks Ralph