Thanks, Martin
take the data from the DensityGraphics
and use
ImageMatrixQ[bm_?MatrixQ] := True
ImageMatrixQ[bm_?(MatrixQ[#, VectorQ] &)] := True
ImageMatrixQ[_] := False
MatrixToImage[data_?ImageMatrixQ] :=
Module[{dim, ny, nx, ch, mind, maxd, colorf},
dim = Dimensions[data];
{ny, nx} = Take[dim, 2];
If[3==Length[dim],
ch = Last[dim],
ch = 1
];
colorf = Switch[ch,
1, GrayLevel,
2, GrayLevel,
3, RGBColor,
4, RGBColor
];
{mind, maxd} = {Min[#], Max[#]} &[Flatten[data]];
If[Sqrt[#.#]&[{mind,maxd}-Round[{mind,maxd}]]<$MachineEpsilon,
{mind, maxd}=Round[{mind, maxd}]
];
If[Abs[maxd-mind]<$MachineEpsilon,
maxd=mind+1
];
Graphics[
Raster[
Developer`ToPackedArray[data], {{0, 0}, {nx, ny}}, {mind, maxd},
ColorFunction -> colorf
], AspectRatio -> Automatic,
PlotRange -> {{0, nx}, {0, ny}}, ImageSize -> {nx, ny}
]
]
the MatrixToImage[] function above.
Regards
Jens