Re: ListDensityPlot[ ] and DensityGraphics
- To: mathgroup at smc.vnet.net
- Subject: [mg17064] Re: ListDensityPlot[ ] and DensityGraphics
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 14 Apr 1999 02:12:08 -0400
- Organization: Universitaet Leipzig
- References: <7es1fo$c82@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Maarten,
1 & 3) I can't help you with your graphics card my SGI show all gray
levels
in correct.
2 & 4) I had the same problem with the white border and have never found
a
solution with Mathematica. You can try to convert the image to
PostScript with
MakeHexString[a_Integer]:=
Module[{dlist},
dlist=IntegerDigits[a,16] /. {10->"A",11->"B",12->"C",13->"D",14->"E",
15->"F"};
If[Length[dlist]<2,
PrependTo[dlist,0]
];
StringJoin @@ (ToString /@ dlist)
]
PSGrayImage[hexStr:{_String..},dims:{_Integer,_Integer}]:=
Module[{xdim,ydim,dimrule},
{xdim,ydim}=ToString /@ dims;
dimrule= {"xx"->xdim,"yy"->ydim};
Graphics[
PostScript[
"0 0 translate",
"1 "<>ToString[N[Last[dims]/First[dims]]]<> " scale",
ToString[2*Apply[Times,dims]] <> " string",
StringReplace[
"xx yy 8 [xx 0 0 yy 0 0]",
dimrule
],
"{currentfile 1 index readhexstring pop } image",
Sequence @@ hexStr,
"pop"
],AspectRatio->Last[dims]/First[dims]
]
]
PSGrayImage[img_ /; MatrixQ[img,IntegerQ]]:=
Module[{maxGray,dims,xdim,ydim,dimrule},
dims=Dimensions[img];
maxGray=255/Max[Flatten[img]];
PSGrayImage[
StringJoin /@
Map[MakeHexString,Map[Round[#*maxGray]&,img,{2}],{2}],
dims
]
]
the HexString function is a bit slow and you may reverse the gray
matrix in the last
definition. to invert the y-direction.
Hope that helps
Jens
Maarten.vanderBurgt at icos.be wrote:
>
> I forgot one question: see 4. below
>
> Hello,
>
> I am trying to write a few simple image processing routines in Mathematica.
> Doing this I came across a few problems using ListDensityPlot and
> displaying DensityGraphics.
> I will explain these questions with a simple example.
>
> I have the following questions:
>
> 1.
> DensPl is a band going from black on the left to white on the right. But
> there are some additional vertical black lines in the centre of the plot.
> These lines disappear when I make the plot bigger by selecting it with the
> mouse and stretching it to say 1.2 times the original size. I get more
> vertical lines when I make the plot smaller in a similar way.
> This seems to be an error/artefact in some interpolation routine when the
> image is resized. This is rather annoying in real life images since from
> the display you can not see what is real and what is a display artefact.
> Is there a way to get rid of this artefact?
>
> 2.
> With the options Mesh ->False, Frame->False,ImageSize->{256,50},
> AspectRatio->Automatic I was hoping the actual size of the black/grey/white
> "colored" area would exactly 50 x 256 pixels on screen (i.e. one element in
> matrix Data would correspond to one pixel in the plot on screen). But
> around the "colored" area there is a white band of 3-5 pixels wide. I there
> a way to get rid of this white band or to control it?
>
> 3.
> - using the "True Color" setting on my display DesnPl is going smoothly
> from black on the left to white on the right.
>
> - using the "16777216 Colors" DensPl is completely black (this is known but
> I do not know the reason: see "[mg15538] Re: ListDensityPlot gives
> PostScript error" from January 26 this year.).
> Does anyone know the difference between "True Color" and "16777216 Colors"?
> I always thought it is the same: true color = 24 bit color = 2^24 =
> 16777216 colors.
> My PC's/graphics card documentation doesn't tell me.
>
> - using the "65536 Colors" (16 bit) setting, DensPl shows approx. 30
> vertical bands with a different grey intensity: it does not vary smoothly
> any more from black to white. I do have other graphics applications which
> have no problem with images showing a smooth grey level variation using the
> 16 bit color setting. Why has Mathematica problems doing this?
>
> 4.
> Is it possible to invert the orientation of the vertical axis in
> ListDensityPlot?
> This would show the image like it is seen in most image processing
> applications.
>
> Any help is greatly appreciated
>
> thanks
>
> Maarten