Ask Your Question

Jep's profile - activity

2016-05-31 06:12:22 -0500 received badge  Notable Question (source)
2015-03-15 04:23:42 -0500 received badge  Popular Question (source)
2012-11-08 05:59:20 -0500 asked a question Android java convertTo

Hi!

I'm trying to use watershed in android. To do so I need a mask of 32f. I have an image with the zones that I want for the watershed, but it is in RGB. I have tried convertTo but it doesn't work. I have done the following test to try the conversion:

Mat maskColor = new Mat( mBitmapPintar.getHeight(), mBitmapPintar.getWidth(), CvType.CV_8UC3);
Mat maskgris = new Mat( maskColor.rows(), maskColor.cols(), CvType.CV_8U );
Mat mask = new Mat( maskColor.rows(), maskColor.cols(), CvType.CV_32S);

maskColor contains the original mask in RGB. I have maskgris to bridge the conversion (it didn't work straight ahead). Now I convert it in gray, then to 32S, back to gray to visualize it and it doesn't work:

Imgproc.cvtColor( maskColor, maskgris, Imgproc.COLOR_BGR2GRAY);
Highgui.imwrite(directoriFitxer + "/maskengris.jpg", maskgris);
mask.convertTo( maskgris, CvType.CV_32F);
maskgris.convertTo(mask,  CvType.CV_8U);
Highgui.imwrite(directoriFitxer + "/maskengrisDespConv.jpg", maskgris);

When I check the two images, the last one maskengrisDespConv.jpg is all in black. What am I doing wrong?