ofImage, ofxCvGrayscaleImage & contrast

Hello,

what I want to do is just load an image and change its contrast…

I tried this to load the image

  
  ofImage loader;  
    ofxCvGrayscaleImage	image;  
      
    float w;  
    float h;  
		  

  
    loader.loadImage("image.jpg");  
      
    image.allocate(loader.getWidth(), loader.getHeight());  
      
    image.setFromPixels(loader.getPixels(),loader.getWidth(), loader.getHeight());  
  
    w = image.getWidth() * 1;  
    h = image.getHeight() * 1;  

but I only get part of the picture displayed and not in ‘good’ resolution

am I doing something wrong ?

try

  
loader.setImageType(OF_IMAGE_GRAYSCALE);  

after loadImage()

1 Like

thanks, it works !

but now I have another problem…

I cannot change the brightness/contrast of the picture…

I have this in my update loop

  
 image.brightnessContrast(brightness, contrast);  

where brightness and contrast are valid floats between -1 and 1 - and it results in just a solid black-to-grey-to-white screen instead of an image…

am I missing sth ?

m