Bug introduced in v9 or earlier and persisting through v10.3.0
There are 3 ways to convert a Raster
into an Image
: only 1 works for me with versions 10.0.1,10.0.2,10.1.0,10.2.0,10.3.0 , and 2 work with version 9 (same computer, OS X 10.9.5)
Has anyone the same problem or is it localized to me and why ?
(This question is actually related to a previous post concerning a problem to import DICOM images)
Here are the tests :
0. The test object
First, let' s define the test object : a Raster
with specific rectangular shape and scale.
data = {{-90, 1, 50}, {30, 0.5, -30}, {75, 1000, -1900}};
shape = {{0, 0}, {10, 2}};
scale = {-100, 100};
myraster = Raster[data, shape, scale];
This is how it looks :
Graphics[myraster, Axes -> True]
For comparison, this is how it looks when you omit the shape and scale :
Graphics[Raster[data], Axes -> True]
1. Image@Raster
According to the documentation (V9 or v10), it should be possible to convert a Raster
primitive directly into an Image object :
Whether I am using version 9 or 10.0.1, the raster is not correctly converted: the shape and scale of the raster were not taken into account !?
Image@myraster
Through@{Head, ImageType, ImageDimensions, Options}[%]
In versions 10.0.2, 10.1.0, 10.2.0,10.3.0 the output is a little bit different but still not correct:
2. Image@Graphics@Raster
This conversion works in version 9 but not in version 10.0.1, 10.0.2, 10.1.0, 10.2.0
Image@Graphics@myraster
Through@{Head, ImageType, ImageDimensions, Options}[%]
The result looks like Image@Raster
:
v10.0.1:
v10.0.2, v10.1.0, v10.2.0, v10.3.0:
v.9 : OK !
3. Rasterize
: OK but ...
According to the documentation (V9 or v10), Image@Graphics
effectively uses the Rasterize
function.
This is OK, it works for me the same way with both v9, but also with v10.0.1, v10.0.2, v10.1.0, v10.2.0, v10.3.0 !
But how is it possible that in v10, Image@Graphics does not work if it effectively uses Rasterize which does work ... !??
4. To sum up