From: jmc on 28 Jul 2010 07:44 Hello, (Platform : WinXP, Active State Tcl/Tk 8.5.8, Img package 1.4) I'm trying to do a conversion from BMP image format -> GIF format using TkImg package. The BMP image has only *4* different colors (it's a corporate logo). When executed from the console, the conversion process ends with an error message "too many colors" One explanation of this could be that a dithering process is made by Tk when reading the image. This dithering yields an new -altered- image for display and increases the number of colors in excess of TkImg capabilities. Question : is this dithering process from Tk possible on a recent computer (my computer has been bought last year) ? Here is a "cut and paste" of what I did (wish) : (Images) 1 % info patchlevel 8.5.8 (Images) 2 % package require Img 1.4 (Images) 3 % set image [image create photo -file logo.bmp] image1 (Images) 4 % $image write test.gif -format GIF too many colors Additionnal precisions : logo.bmp file size is 104 ko test.gif file size is about 6 ko and unrecognised when trying to read it... Many thanks Jean-Marie
From: Donal K. Fellows on 28 Jul 2010 08:42 On 28 July, 12:44, jmc <jm.c...(a)orens.fr> wrote: > I'm trying to do a conversion from BMP image format -> GIF format > using TkImg package. The BMP image has only *4* different colors > (it's a corporate logo). When executed from the console, the > conversion process ends with an error message "too many colors" > > One explanation of this could be that a dithering process is made by > Tk when reading the image. This dithering yields an new -altered- > image for display and increases the number of colors in excess of > TkImg capabilities. Tk only dithers images on display. The data-model is undithered. Instead, I suspect the problem is that the logo is antialiased in the source file, which means that there are a *lot* more than 4 colours in there. You can check this for yourself by computing a histogram of the source image. See http://rosettacode.org/wiki/Bitmap/Histogram#Tcl for how to do that. Donal.
From: jmc on 28 Jul 2010 12:47 On 28 juil, 14:42, "Donal K. Fellows" <donal.k.fell...(a)manchester.ac.uk> wrote: > On 28 July, 12:44, jmc <jm.c...(a)orens.fr> wrote: > > > I'm trying to do a conversion from BMP image format -> GIF format > > using TkImg package. The BMP image has only *4* different colors > > (it's a corporate logo). When executed from the console, the > > conversion process ends with an error message "too many colors" > > > One explanation of this could be that a dithering process is made by > > Tk when reading the image. This dithering yields an new -altered- > > image for display and increases the number of colors in excess of > > TkImg capabilities. > > Tk only dithers images on display. The data-model is undithered. > > Instead, I suspect the problem is that the logo is antialiased in the > source file, which means that there are a *lot* more than 4 colours in > there. You can check this for yourself by computing a histogram of the > source image. Seehttp://rosettacode.org/wiki/Bitmap/Histogram#Tclfor > how to do that. > > Donal. Thanks Donal. Color histogram is a nice idea. I tried to use the script you pointed to me, but have to give up mainly because this script seems to be incomplete (the proc "histogram" is just storing a map of luminences of each pixel in a dict. IMHO, the frequencies for each luminences remains to be computed..., and then to be displayed in a intelligible maner...) Thanks again Jean-Marie
From: Alexandre Ferrieux on 28 Jul 2010 16:55 On Jul 28, 6:47 pm, jmc <jm.c...(a)orens.fr> wrote: > On 28 juil, 14:42, "Donal K. Fellows" > > > > > > <donal.k.fell...(a)manchester.ac.uk> wrote: > > On 28 July, 12:44, jmc <jm.c...(a)orens.fr> wrote: > > > > I'm trying to do a conversion from BMP image format -> GIF format > > > using TkImg package. The BMP image has only *4* different colors > > > (it's a corporate logo). When executed from the console, the > > > conversion process ends with an error message "too many colors" > > > > One explanation of this could be that a dithering process is made by > > > Tk when reading the image. This dithering yields an new -altered- > > > image for display and increases the number of colors in excess of > > > TkImg capabilities. > > > Tk only dithers images on display. The data-model is undithered. > > > Instead, I suspect the problem is that the logo is antialiased in the > > source file, which means that there are a *lot* more than 4 colours in > > there. You can check this for yourself by computing a histogram of the > > source image. Seehttp://rosettacode.org/wiki/Bitmap/Histogram#Tclfor > > how to do that. > > > Donal. > > Thanks Donal. > > Color histogram is a nice idea. > > I tried to use the script you pointed to me, but have to give up > mainly because this script seems to be incomplete (the proc > "histogram" is just storing a map of luminences of each pixel in a > dict. IMHO, the frequencies for each luminences remains to be > computed..., and then to be displayed in a intelligible maner...) > Nope, reread that code ;-) [dict incr] does compute frequencies... -Alex
From: jmc on 29 Jul 2010 10:17
On 28 juil, 22:55, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote: > On Jul 28, 6:47Â pm, jmc <jm.c...(a)orens.fr> wrote: > > > > > On 28 juil, 14:42, "Donal K. Fellows" > > > <donal.k.fell...(a)manchester.ac.uk> wrote: > > > On 28 July, 12:44, jmc <jm.c...(a)orens.fr> wrote: > > > > > I'm trying to do a conversion from BMP image format -> GIF format > > > > using TkImg package. The BMP image has only *4* different colors > > > > (it's a corporate logo). When executed from the console, the > > > > conversion process ends with an error message "too many colors" > > > > > One explanation of this could be that a dithering process is made by > > > > Tk when reading the image. This dithering yields an new -altered- > > > > image for display and increases the number of colors in excess of > > > > TkImg capabilities. > > > > Tk only dithers images on display. The data-model is undithered. > > > > Instead, I suspect the problem is that the logo is antialiased in the > > > source file, which means that there are a *lot* more than 4 colours in > > > there. You can check this for yourself by computing a histogram of the > > > source image. Seehttp://rosettacode.org/wiki/Bitmap/Histogram#Tclfor > > > how to do that. > > > > Donal. > > > Thanks Donal. > > > Color histogram is a nice idea. > > > I tried to use the script you pointed to me, but have to give up > > mainly because this script seems to be incomplete (the proc > > "histogram" is just storing a map of luminences of each pixel in a > > dict. IMHO, the frequencies for each luminences remains to be > > computed..., and then to be displayed in a intelligible maner...) > > Nope, reread that code ;-) > [dict incr] does compute frequencies... > > -Alex Ok. Thanks Alex to pointing on my mistake. Now I kwow my source file has too many colors to be processed by the TkImg package. So I tried to convert its image format using ImageMagick "convert" utility. From the command.com shell (WinXP): "convert logo.bmp logo.gif" works fine. But if I try from Tcl to do "exec convert logo.bmp logo.gif", Tcl returns an error message for the last argument I can't figure why. Here is what I did : Trentor) 5 % exec convert logo.bmp logo.gif ParamÅ tre non valide - logo.gif Thanks Jean-Marie |