MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ListDensityPlot and GraphicsArray

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65549] Re: ListDensityPlot and GraphicsArray
  • From: "buttgereit at biomediclab.de" <buttgereit at biomediclab.de>
  • Date: Fri, 7 Apr 2006 06:14:25 -0400 (EDT)
  • References: <e0r06j$li$1@smc.vnet.net><e12tf1$jfs$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Jens,

thanks for the response.
Of course, Your code works on the picture (<g> who would have thought).

What bothers me is that I don't see what's the problem with the array
I feed into ListDensityPlot.

Do You have an idea?

In[3]:=
ListDensityPlot[toobig , Mesh -> False]

>From In[3]:=
DensityGraphics::"gmat": " <<1>> is not a rectangular array larger than
2 x 2."

Out[3]=
- DensityGraphics -

In[4]:=Dimensions[toobig]
Out[4]={400, 300}

In[5]:=Union[NumberQ /@ Flatten[toobig]]
Out[5]={True}

In[6]:=Union[Length /@ toobig]
Out[6]={300}

In[7]:=Union[Length /@ Transpose[toobig]]
Out[7]={400}

In[8]:={Max[#], Min[#]} &@Flatten[toobig]
Out[8]={108.9, 0.0582891}

In[9]:=Union[Head /@ Flatten[toobig]]
Out[9]={Real}


Thanks + Best Regards,

Peter


Jens-Peer Kuska schrieb:

> 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
> >


  • Prev by Date: Re: Sphere
  • Next by Date: Re: Permutations
  • Previous by thread: Re: ListDensityPlot and GraphicsArray
  • Next by thread: Re: ListDensityPlot and GraphicsArray