1
$\begingroup$

I am trying to create an animation with a graphic of an arm that can bend at the elbow. For this purpose I created the following two images: hand1 and hand2. I load the images with

img1 = Import["...\\hand1.png"];
img2 = Import["...\\hand2.png"];

where instead of ... I put the proper path to the files. Next, since I want to have a handle on the position of each image within a frame of a certain size, I Inset the images into Graphics objects:

Gimg1 = Graphics[Inset[img1, {0, 0}, {199.5, 141.5}, 400], PlotRange -> {{-199.5, 199.5}, {-141.5, 141.5}}];
Gimg2 = Graphics[Inset[img2, {0, 0}, {199.5, 141.5}, 400], PlotRange -> {{-199.5, 199.5}, {-141.5, 141.5}}];

Now, if I try to Show one picture on top of the other, I see that the Graphics objects give a color artifact at the boundary where the two images overlap:

Show[{Gimg2, Gimg1}]

Here I have zoomed in and made a screenshot of the problematic region:

enter image description here

(the black arrow points towards the "intersection region" where the artifact appears in the form of a line of slightly lighter color than the usual background. The same lightening of color also appears at all other edges. You might have to tilt your screen up a bit to see it clearly.) On the other hand, if I directly overlap the two imported images, this artifact does not show up:

Show[{img2, img1}]

Here the corresponding zoom screenshot:

enter image description here

I really would like to use the Graphics wrapper, since it allows to change the image coordinates within the frame, but the artifact above is annoying and basically a deal breaker. What should I do to get rid of this artifact? Maybe there is an other function that can display images and offers access to display coordinates? Thanks for any suggestion.

$\endgroup$
2
$\begingroup$

It turned out that for some reason the image got re-sized to a slightly different pixel width and height. Fixing the width explicitly to the original value removed the artifacts:

Gimg1 = Graphics[Inset[img1, {0, 0}, {199.5, 141.5}, 400], PlotRange -> {{-199.5, 199.5}, {-141.5, 141.5}}, ImageSize -> 400];
Gimg2 = Graphics[Inset[img2, {0, 0}, {199.5, 141.5}, 400], PlotRange -> {{-199.5, 199.5}, {-141.5, 141.5}}, ImageSize -> 400];
Show[{Gimg2, Gimg1}]
$\endgroup$

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.