ofxCvFloatImage::setFromPixels issue?

Hello everybody!

I’m experiencing an issue whilst trying to set a ofxFloatImage from an array of floats.

What I like to do is in fact quite simple: I’m having a float array, the size of 320*240 and an allocated ofxFloatImage with the same dimensions. When I’m assigning the float array to the empty image by calling setFromPixels(array, width, height) and drawing it, only “the first part” of the image is visible, the rest of it is black. Curiously, the visible area is exactly as wide as a fourth of the total width. While debugging I recognized that widthStep is equal to 1280 during the call of ofxCvFloatImage::setFromPixels, shouldn’t that be 320 in my case?

What could I be doing wrong here?

Thx for any hints on that one!
-digivox-

hi digivox,

it sounds like ofxFloatImage is expecting RGBA data (320*4=1280)… i’m not sure if there’s an ofxFloatGrayscaleImage but that’s probably more what you want :slight_smile:

hth
d

[quote author=“damian”]it sounds like ofxFloatImage is expecting RGBA data (320*4=1280)… i’m not sure if there’s an ofxFloatGrayscaleImage but that’s probably more what you want :slight_smile:

-digivox-

ohhh… so what’s happening then, is that getPixels is returning an unsigned char*, so when you walk through it sets bytes (8 bit, 8x4=32) rather than floats (32 bit)…

try this instead:

  
float* pixels = (float*)myFloatImage->getPixes();  
// iterate over pixels as though it is 640x480..  

hm, thanks for you answer! I simply fixed the problem by normalizing my floats and using an ofxCvGrayscaleImage instead. should be faster anyway…

-digivox-