Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to convert an 8-bit OpenCV IplImage* to a 32-bit IplImage*?
    primarykey
    data
    text
    <p>I need to convert an 8-bit IplImage to a 32-bits IplImage. Using documentation from all over the web I've tried the following things:</p> <pre><code>// general code img2 = cvCreateImage(cvSize(img-&gt;width, img-&gt;height), 32, 3); int height = img-&gt;height; int width = img-&gt;width; int channels = img-&gt;nChannels; int step1 = img-&gt;widthStep; int step2 = img2-&gt;widthStep; int depth1 = img-&gt;depth; int depth2 = img2-&gt;depth; uchar *data1 = (uchar *)img-&gt;imageData; uchar *data2 = (uchar *)img2-&gt;imageData; for(h=0;h&lt;height;h++) for(w=0;w&lt;width;w++) for(c=0;c&lt;channels;c++) { // attempt code... } // attempt one // result: white image, two red spots which appear in the original image too. // this is the closest result, what's going wrong?! // see: http://files.dazjorz.com/cache/conversion.png ((float*)data2+h*step2+w*channels+c)[0] = data1[h*step1+w*channels+c]; // attempt two // when I change float to unsigned long in both previous examples, I get a black screen. // attempt three // result: seemingly random data to the top of the screen. data2[h*step2+w*channels*3+c] = data1[h*step1+w*channels+c]; data2[h*step2+w*channels*3+c+1] = 0x00; data2[h*step2+w*channels*3+c+2] = 0x00; // and then some other things. Nothing did what I wanted. I couldn't get an output // image which looked the same as the input image. </code></pre> <p>As you see I don't really know what I'm doing. I'd love to find out, but I'd love it more if I could get this done correctly. Thanks for any help I get!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload