CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: CImg library

  1. #1
    Join Date
    Feb 2006
    Posts
    2

    CImg library

    Hi everyono, I am using CImg library, and have a problem. I constructed 48*32 grayscale imag with:

    CImg<double> image(48,32,1,1,0);

    After that if, for instance i want to put some pixel to values 126, i use:

    for(int i=0;i<48;i++){
    for(int j=0;j<3;j++){
    image(i,j)=126;}}

    and than try to display that by:

    CImgDisplay display(image);

    All i get is black and white image, and i want to get a grayscale image, Can somebody tell what am i doing wrong.
    Thanks in advance
    Uros

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: CImg library

    [ moved thread ]
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Feb 2005
    Posts
    58

    Re: CImg library

    perhaps you should try to change the value to 0.5 instead of 126. When graphics libraries use doubles or floating points the values often go from 0 to 1 instead of 0 to 255.

  4. #4
    Join Date
    Dec 2006
    Posts
    2

    Re: CImg library

    halo,
    I would like to know did u get to convert the RGB images into grayscale images? im a newbie n im currently facing d problem n hope u can help if u've figured out how 2do it.
    thanks.

  5. #5
    Join Date
    Aug 2005
    Posts
    478

    Re: CImg library

    There are many formulas but a common one is

    greyscale = 0.3 * red + 0.59 * green + 0.11 * blue

    This thread is ancient, there is no reason for you to have revived it.
    Windows XP, Visual Studio 2008, SVN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured