OpenCV IplImage

This is a discussion on OpenCV IplImage within the C++ Programming forums, part of the General Programming Boards category; good day all, i am using openCV to load a color bmp file, i use: Code: IplImage* image = cvLoadImage("Color.bmp",1); ...

  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, 11:06 AM
  4. OpenCV Library - problems with dll files
    By nipun in forum Windows Programming
    Replies: 3
    Last Post: 11-21-2004, 09:36 AM
  5. IPL and OpenCV libraries HELP!!!!
    By dima in forum C++ Programming
    Replies: 0
    Last Post: 11-04-2004, 04:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21