Re: ListDensityPlot and GraphicsArray
- To: mathgroup at smc.vnet.net
- Subject: [mg65531] Re: ListDensityPlot and GraphicsArray
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 6 Apr 2006 06:52:45 -0400 (EDT)
- References: <e0r06j$li$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, I can't reproduce your problem and as long as I can't see what your RGB to Lab conversion does I can tell you anything. But ftoxyz = Compile[{{rgb, _Real}}, 100*If[rgb > 0.04045, ((rgb + 0.055)/1.055)^2.4, rgb/12.94] ]; RGBtoXYZ[rgb_List, max_:255] := With[{m = {{0.4124, 0.3576, 0.1805}, {0.2126, 0.7152 , 0.0722}, {0.0193 , 0.1192, 0.9505}}}, Module[{varRGB}, varRGB = ftoxyz /@ (N[rgb/max]); m.varRGB ] ] ftolab = Compile[{{xyz, _Real}}, If[xyz > 0.008856, xyz^(1/3), (7.787*xyz) + (16/116)]]; Clear[XYZtoCIELab] XYZtoCIELab[xyz_List] := Module[{vx, vy, vz}, {vx, vy, vz} = ftolab /@ (xyz/{95.047, 100.000, 108.883}); {116*vy - 16, 500*(vx - vy), 200*(vy - vz)} ] RGBToCIELab[rgb_List, max_:255] := Round /@ XYZtoCIELab[RGBtoXYZ[rgb, max]] img = Import["G:/images/leopard.jpg"]; labimg = img /. Raster[bm_, args___] :> Raster[Map[RGBToCIELab, bm, {2}], args]; ListDensityPlot[Map[#[[2]] &, labimg[[1, 1]], {2}], Mesh -> False, AspectRatio -> Automatic] work fine. Regards Jens buttgereit at biomediclab.de wrote: > Dear Group, > > using Mathematica 5.0 on WinXP I have a strange problem with > ListDensityPlot. > > I have imported a picture (PNG) using > > img=Import["mypic.png"]; > > I can show it, all fine so far. > > I then extract the pixel data (rgb in this case) using > > raster=img//First//First; > > I extract the red channel using > > rc=Map[First,raster,{2}]; > > and can display it with > > ListDensityPlot[rc]; > > However, when I convert the raster to Lab color space and extract, say > the illumination > > ListDensityPlot[lc]; > > fails with > > "DensityGraphics::gmat: ... is not a rectangular array larger than 2 x > 2" > > But the size is identical to rc according to > > Dimension[rc] is equal to Dimension[lc] : {400,300}. > > Just Reals instead of Integers -- and though, rounding/scaling does not > make a difference. > > I have checked the array using > > Union[Length/@lc] > > which evaluates to {400} in this case -- doesn't this say it _is_ > rectangular? Do I miss something? > > I can show part of the array using Take and define a region of at most > 200x200 pixels -- expanding it again pops the error. I can move that > "window" over the image without errors. > Just expanding it does not work. > > Any idea what could cause the problem? ( yes, I did restart windows ;) > > Best Regards, > > Peter >