TransWikia.com

Unwanted scaling when overlaying GraphicsComplex graphic onto image?

Mathematica Asked by Gnaprs on April 10, 2021

I have a collection of complex hull meshes, which I would like to overlay onto an image. These complex hull meshes were obtained from the original image, and I have verified that their mesh coordinates (pastebin link for reference) are close to the original bounds of the image of size {2752,2192} pixels.

Convex hull meshes

However, converting their mesh coordinates to a GraphicsComplex graphic seems to resize the output image to {360,282} instead of a larger graphic near the size {2752,2192}.

ImageDimensions@[Graphics[GraphicsComplex[MeshCoordinates[#], {Thick, Red, MeshCells[#, 1]}]] & /@ allCluster]
ImageDimensions@pic

Output: {360, 282}, {2752, 2192}

As a result, overlaying the complex hull meshes over the original image results in a translated/scaled offset that I’m unable to fix.
Show[pic, Graphics[GraphicsComplex[MeshCoordinates[#], {Thick, Red, MeshCells[#, 1]}]] & /@ allCluster]

scaled overlay

This used to work in an older version of Mathematica (12.0.2), but since upgrading to the 12.2 I have been unable to obtain the same overlays that I used to get.
correct overlay with older version of mathematica

Is there an option to output Graphics at its original size instead of rescaling so that I can overlay my images properly? I have tried adding an ImageSize parameter as such, to no avail. I have also tried using ImageResize, but got the same image with the red outlines in a lower resolution.

Show[pic, Graphics[GraphicsComplex[MeshCoordinates[#], {Thick, Red, MeshCells[#, 1]}], ImageSize -> {2752, 2192}] & /@ allCluster]

Thank you!

One Answer

Still not sure why Show scales the meshes, but HighlightImage gives me exactly what I want!

HighlightImage[pic, Graphics[GraphicsComplex[MeshCoordinates[#], {Thick, Red, MeshCells[#, 1]}]] & /@ allCluster]

correct overlay

Correct answer by Gnaprs on April 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP