Ask Your Question

reem's profile - activity

2017-03-21 07:34:27 -0600 received badge  Popular Question (source)
2014-04-10 09:36:30 -0600 commented question Resize matrix in Java

Hey,

using a float-array instead of an int-array solved the problem. And dont forget to change the

CvType.CV_32F

But of course I had to waste more memory, because of the unneeded float-arrays...

Regards, reem

2014-04-09 12:17:15 -0600 commented question Resize matrix in Java

but it doesent work with other types. if you want to reproduce the error, here some code:

float[] a = {   64000f, 12000f, 1f, 2f };
        Mat src = new Mat(2, 2, CvType.CV_32S);
        src.put(0, 0, a);       
        Mat dst = new Mat();
        Imgproc.resize(src, dst, src.size(), 0.5, 0.5,
                Imgproc.INTER_LINEAR);
2014-04-09 11:54:11 -0600 commented question Resize matrix in Java

the img16u-matrix is quadratic. but I really dont understand the problem. or maybe the resize()-method is not able to resize() 32Bit-singned-Int Matrices.

2014-04-09 11:37:33 -0600 commented question Resize matrix in Java

of course, the new liveMatHalfRawData-matrix should have the half size of the old one. that means to me, that rows and cols schould be half also.

2014-04-09 11:26:32 -0600 asked a question Resize matrix in Java

Hello,

I am trying to resize a matrix of CvType.CV_32S to a smaller matrix. Every time I use the Imgproc.resize() methode, I am getting the following exception:

OpenCV Error: Assertion failed (func != 0) in cv::resize, file ........\opencv\modules\imgproc\src\imgwarp.cpp, line 1970 CvException [org.opencv.core.CvException: cv::Exception: ........\opencv\modules\imgproc\src\imgwarp.cpp:1970: error: (-215) func != 0 in function cv::resize ]

My code looks linke this:

Imgproc.resize(img16u, liveMatHalfRawData, new Size(img16u.rows()/2,img16u.cols()/2), 0, 0,
                Imgproc.INTER_CUBIC);

Thanks for help,

reem

2014-04-09 11:05:48 -0600 commented answer How to resize a Mat in Opnecv4Android

The same call: Imgproc.resize() throws an Exception:

OpenCV Error: Assertion failed (func != 0) in cv::resize, file ........\opencv\modules\imgproc\src\imgwarp.cpp, line 1910...

Maybe you know why? Thx

2014-04-03 10:55:54 -0600 answered a question Read 16bit binary file in Java

I found the solution as following:

  • matrix was emtpy because the value of the cols wasn't set
  • The transformation of an 16 bit - raw file with 0-65k greyvalues into a 24bit - RGB JPEG works fine

If someone has any idea how I could manage the in-reading of an 16 bit unsigned int into java without using an char-Array, please tell me. The transformation is done with the following code:

img16u.convertTo(imgtmp, CvType.CV_8UC3, (double) 255.0
            / (maxVal - minVal), (double) -minVal * 255.
            / (maxVal - minVal));

Regards, reem

2014-03-28 07:39:18 -0600 commented question Read 16bit binary file in Java

Sorry I really dont get it. Why is my matrix empty?

Mat.put(0,0,myArray)

-->returns an empty map and I really don't know why. I debugged it and everything seems ok.

2014-03-28 07:11:52 -0600 commented question Read 16bit binary file in Java

that's why I was reading it first in an byte-array. than I convert it to an int-array. the values of the int-array are right. all I want to do is to put my int-array to the matrix.

is this not possible? I rewrite a python script wich do exactly the same.

f = open( filename, 'rb' )

f.seek( raw.headerlen )

data = np.fromstring( f.read(), dtype=np.uint16 )

f.close()

img = cv.CreateMat( raw.width, raw.height, cv.CV_16UC1 )

cv.SetData( img, data )
2014-03-28 07:00:47 -0600 commented question Read 16bit binary file in Java

but if I do it like this, I get an empty map:

Mat imgMat = Highgui.imread("a.raw",0); imgMat.convertTo(imgMat, CvType.CV_16UC1); System.out.println(imgMat.size());

And I can't jump over the header

2014-03-28 06:34:14 -0600 received badge  Editor (source)
2014-03-28 06:29:54 -0600 asked a question Read 16bit binary file in Java

Hello everyone, I'm trying now for about three days to solve the following problem. I Just want to read a binary file with Java and put all the values to an Opencv-Mat-Objekt. I know that all the datavalues in my input-image are greyvalues from 0-65k. My code looks like:

    byte[] rawFile = Files.readAllBytes(Paths.get("a.raw"));

// header is cut off, only date in file left
byte[] data = Arrays.copyOfRange(rawFile, 2048, rawFile.length);

// bytearray --> char array (16bit unsigned)
CharBuffer cBuf = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN)
            .asCharBuffer();
char[] cArray = new char[cBuf.remaining()];
cBuf.get(cArray);

int[] finalData = new int[cArray.length];
// cast  all char values to int-values
for (int i = 0; i < cArray.length; i++) {
   finalData[i] = (int) cArray[i];
    }

So far so good. My values look good in the finalData-Array. But whem I'm tryin to put it in an OpenCv-Mat-Object, the matrix is emtpy. I add the finalData-array like this to the matrix:

    Mat img16u = new Mat();
    img16u.create(raw.getWidth(), raw.getHeight(), CvType.makeType(CvType.CV_32SC1, 1));
    img16u.put(0, 0, finalData);

But I'm not sure if the CvType is right or not.

Maybe someone has any Idea how to solve this.

Regards, reem