Click to See Complete Forum and Search --> : CImg library


uroshrs
February 8th, 2006, 07:31 AM
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

Marc G
February 8th, 2006, 08:32 AM
[ moved thread ]

GaboonViper
February 8th, 2006, 08:37 AM
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.

san_squared
December 9th, 2006, 06:35 AM
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.

Calculator
December 9th, 2006, 10:53 AM
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.