Re: Undocumented functions for working with graphics

*To*: mathgroup at smc.vnet.net*Subject*: [mg101133] Re: Undocumented functions for working with graphics*From*: David Reiss <dbreiss at gmail.com>*Date*: Thu, 25 Jun 2009 07:10:24 -0400 (EDT)*References*: <h0qogh$kkq$1@smc.vnet.net> <h0sbok$h8i$1@smc.vnet.net>

Hi there... When I posted the result to MathGroup, I did edit it a bit to remove the Image`ImageDump` context prefixes so that it would be easier to read. I simply did a global replace for the string Image`ImageDump` so that the resulting code fragment would be more readable. These bits of code that are high level Mathematica code often have these various contexts in them based on how Wolfram research handles internal not-for-general-consumption Mathematica code. Also some folks may have noticed that one gets a different answer if one tries to obtain the code in a fresh Mathematica session. This is because the code in some of these these contexts is not loaded until one actually tries to first make use fo the function. So, for example, executing something like Image[ {{0, 1, 0}, {1, 0, 1}, {0, 1, 0}}] Will load that code and then subsequently going through the process that I outlined will create the code that I showed. Best, David http://scientificarts.com/worklife On Jun 24, 6:34 am, Alexey <lehi... at gmail.com> wrote: > Thank you very much! The method you have described is great. Some > times for using it I must launch Mathematica with "-cleanStart" key > for clearing the dump. But for Image`ToGraphicsRaster I can not get > your "clear" code. My result contains unknown functions like > Image`ImageDump`list with no attributes: > > In[1]:= ClearAttributes[Image`ToGraphicsRaster, {Protected, > ReadProtected}] > ?Image`ToGraphicsRaster > > Output: > > Image`ToGraphicsRaster[Image`ImageDump`list:{_? > Image`ValidImageQ..}]:=Image`ToGraphicsRaster/@Image`ImageDump`list > > Image`ToGraphicsRaster[Image`ImageDump`img_?Image`ValidImageQ]:=Module > [{Image`ImageDump`width,Image`ImageDump`height,Image`ImageDump`range,Imag= e` = > ImageDump`cf,Image`ImageDump`data,Image`ImageDump`interleaving,Image`Imag= eD = > ump`imsize}, > {{Image`ImageDump`width,Image`ImageDump`height},Image`ImageDump`range,Ima= ge = > `ImageDump`cf} > =ImageData[Image`ImageDump`img, > {ImageDimensions,DataRange,ColorFunction}]; > {Image`ImageDump`interleaving,Image`ImageDump`imsize}= > {Interleaving,ImageSize}/.Options[Image`ImageDump`img]/.Options > [Image];If > [Image`ImageDump`interleaving===False,Image`ImageDump`data=Revers= e > [ImageData[Image`ImageDump`img,Interleaving->True]],Image`ImageDump`data= =Reverse[First > > [Image`ImageDump`img]]];Graphics[Raster[Image`ImageDump`data,{{0,0}, > {Image`ImageDump`width,Image`ImageDump`height}},Image`ImageDump`range,Col= or = > Function->Image`ImageDump`cf],If[Image`ImageDump`imsize===Automatic= || > > Image`ImageDump`imsize===All,ImageSize-> > {Image`ImageDump`width,Image`ImageDump`height},ImageSize->Image`ImageDump= `imsize],PlotRange->{{0,Image`ImageDump`width}, > > {0,Image`ImageDump`height}}]] > > How did you get your "clear" code? > > On 12 Jun, 05:41, David Reiss <dbre... at gmail.com> wrote: > > > > > ...just following up on the method for reverse engineering of my > > previous post, here is part of the code for ToGraphicsRaster obtaine= d > > using that approach: > > > Image`ToGraphicsRaster[img_?Image`ValidImageQ] := > > Module[{width, height, range, cf, data, interleaving, > > imsize}, {{width, height}, range, cf} = > > ImageData[ > > img, {ImageDimensions, DataRange, ColorFunction}]; {interleavin= g, > > imsize} = {Interleaving, ImageSize} /. Options[img] /. > > Options[Image]; > > If[interleaving === False, > > data = Reverse[ImageData[img, Interleaving -> True]], > > data = Reverse[First[img]]]; > > "Graphics"[ > > Raster[data, {{0, 0}, {width, height}}, range, > > ColorFunction -> cf], > > If[imsize === Automatic || imsize === All, > > ImageSize -> {width, height}, ImageSize -> imsize], > > PlotRange -> {{0, width}, {0, height}}]] > > > On Jun 11, 7:06 am, Alexey <lehi... at gmail.com> wrote: > > > > Hello, > > > > Does anyone know where such functions as "Image`ToGraphicsRaster" = an= > d > > > "Image`PossibleImageQ" are documented. Are there other such built-in > > > functions? At this moment I even can't imagine from where (except thi= s > > > group) I could learn that functions mentioned exist...