Search code examples
opencvjavacv

Convert IPL_DEPTH_16S image in to IPL_DEPTH_8U in JavaCV


I have a One Image with depth of IPL_DEPTH_16S

IplImage result = cvCreateImage(cvGetSize(smoothImage), IPL_DEPTH_16S, 1);
cvSobel(smoothImage, result, 0, 1, 3);

and i want to pass that result image to other object which needs an IPL_DEPTH_8U image. So Is there any way to convert IPL_DEPTH_16S to IPL_DEPTH_8U in JavaCV.

I already try to use cvConvertScale() method. But i can't find what are the exact parametrs for that method.

Thankx..


Solution

  • Using the same style as your code, this should work:

    IplImage i = cvCreateImage(cvGetSize(result), IPL_DEPTH_8U, 1);
    cvConvertScale(result, i, 1, 0);