Thread: OpenCV IplImage

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    2

    OpenCV IplImage

    good day all,

    i am using openCV to load a color bmp file, i use:

    Code:
    IplImage* image = cvLoadImage("Color.bmp",1);
    the data is stored as a char*

    i wish to convert this data into a RGB float array.

    however if i simply go through the string and convert each char using a (float) cast, i sometimes end up with negative numbers.

    is there a proper way of converting chars that represent color values into proper floats without getting negs ??

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    30
    You need to cast your char to unsigned char first, as the RGB values can range from 0~255, which is the range of unsigned chars. Signed chars' range is -128~127. When a RGB value is greater than or equal to 128 and you convert it directly, you get a negative.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    2
    fantastic it works thanks, i was beginning to run out of hair to pull out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opencv thread safe?
    By mynickmynick in forum C Programming
    Replies: 3
    Last Post: 05-21-2008, 10:01 AM
  2. Displaying an IplImage in an Extended Windows Styles window
    By Tankndozer in forum Windows Programming
    Replies: 0
    Last Post: 08-10-2005, 05:22 AM
  3. OpenCV Function help
    By cathy_e in forum C Programming
    Replies: 0
    Last Post: 02-28-2005, 12:06 PM
  4. OpenCV Library - problems with dll files
    By nipun in forum Windows Programming
    Replies: 3
    Last Post: 11-21-2004, 10:36 AM
  5. IPL and OpenCV libraries HELP!!!!
    By dima in forum C++ Programming
    Replies: 0
    Last Post: 11-04-2004, 05:21 AM