5
$\begingroup$

How to get sharp pixel boundaries with Texture? I'd like to have only black/white in the example below, no gray.

a := Image[Table[If[EvenQ[x + y], 1, 0], {x, 50}, {y, 50}]];
Graphics[{Texture[a],
  Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, 
   VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}, ImageSize -> 200]

enter image description here

$\endgroup$
7
$\begingroup$

Not too hard.

a = Image[Table[If[EvenQ[x + y], 1, 0], {x, 50}, {y, 50}], ImageSize -> Large];

Graphics[{Texture[a], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}},
                              VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}]

textured triangle

$\endgroup$
  • $\begingroup$ That's much better, thank you. On a PDF export, still have gray transitions, however. Do you know if this is avoidable? $\endgroup$ – Frank May 18 '13 at 16:29
  • $\begingroup$ Ah, that I don't know about. Could you mention what version and OS are you on, to help with the diagnosis? $\endgroup$ – J. M. will be back soon May 18 '13 at 16:33
  • 1
    $\begingroup$ Mathematica 9.0.1.0 on Windows 8, 64-bit $\endgroup$ – Frank May 18 '13 at 16:34
  • $\begingroup$ Hmm... do you also get the gray transitions if you export a as a PDF? $\endgroup$ – J. M. will be back soon May 18 '13 at 16:36
  • 1
    $\begingroup$ @bobthechemist: For B/W, yes, although I have not measured if now either black or white pixels appear larger. On color images, it does not work. I think, it's a fundamental issue with the way Texture is implemented. I'd love it if there was an option like Resampling -> "Nearest" in ImageResize for Texture. $\endgroup$ – Frank May 18 '13 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.