Ask Your Question
0

Split BGR into 3 separate images

asked 2016-12-30 19:52:40 -0600

Ralph058 gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-12-30 21:15:00 -0600

berak gravatar image

updated 2016-12-30 21:16:46 -0600

imgR = imgBGR_R[3]

valgrind is right.: imgBGR_R[2] is the largest valid index (starting from 0)

same for imgBGR_L

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-30 19:52:40 -0600

Seen: 485 times

Last updated: Dec 30 '16