This post is related to this post, But somewhat different. Since Wizard focus on alpha channel, and didn't got an answer. So I made this post.
My system is Windows 10, and Mathematica 11.2
If I run
plot = Image[RandomReal[1., {6, 6}]]
I got
Then I texture this image on a square like this
Graphics[{Texture[plot], EdgeForm[],
Append[Polygon @@ RegionBoundary[Rectangle[]],
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]
I got
You can see it is already blurred
What is worse, if we generate a color image
plot = Image[RandomReal[1., {6, 6, 3}]]
and texture it.
Graphics[{Texture[plot], EdgeForm[],
Append[Polygon @@ RegionBoundary[Rectangle[]],
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]
I got
Which is a total mess.
The difference between my result and Wizard's result is that, even I don't set alpha channel, I already screw up the color image texture.
So why Texture
always blur image? I check the doc, it seems that this blurring feature is not mentioned. Is it possible to make Texture
clear especially for color image generated by Image
?
update
Thanks to J.M. and kglr. They both suggest that it is a problem of low-res of image. But I have a counter example, which suggest that there is some subtle effect. Take a look at this, using ArrayPlot
plot = ArrayPlot[RandomReal[1., {6, 6}], ColorFunction -> "Rainbow",
Frame -> None]
then texture it with the same method,
Graphics[{Texture[plot], EdgeForm[],
Append[Polygon @@ RegionBoundary[Rectangle[]],
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]
you will got
You will notice there is still some blur, but much weaker. And the color is much much better than Image
texture, but seems not as vivid as original plot.
If you test ImageDimensions@plot
. Both ArrayPlot
and Image
generate 6x6 image. So at least, this example shows low-res may not be a real reason for poor texture of Image
plot = Image[RandomReal[1., {6, 6}], ImageSize -> 500]
? $\endgroup$plotNew = ImageResize[plot, Scaled[50], Resampling -> "Nearest"]; Graphics[{Texture[plotNew], EdgeForm[], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]
$\endgroup$Rasterize[plot ,RasterSize ->500, ImageResolution -> 300 ]
also works in both v9 an v11. $\endgroup$Texture[]
: "Texture[obj]
is equivalent toTexture[Rasterize[obj]]
and will rasterizeobj
at the size and resolution it would normally be displayed in a notebook." With that, tryplot = Rasterize[ArrayPlot[RandomReal[1., {6, 6}], ColorFunction -> "Rainbow", Frame -> None]]; ImageDimensions[plot]
. $\endgroup$