Mathematica Asked on September 30, 2021
My scripts that use HighlightImage stopped working after upgrading to 12.
I discovered that HighlightImage doubles the Dimensions of the image, see below. Bug ?? workaround ? I need the exact same image as the original, only with a marker superimposed.
HighlightImage
returns a Graphics
object, not an Image
.
HighlightImage[img, {120, 120}] // Head
Graphics
When you call ImageDimensions
, Rasterize
is invoked internally to create an Image
object to find the dimensions of. I believe it was V12 that Rasterize
got an overhaul to work with high dpi screens.
A regular screen is 72 dpi (or 96 on Windows I think). Modern macs are 144 though:
$OperatingSystem
"MacOSX"
CurrentValue["ConnectedDisplays"]
{{"Region" -> {{0., 1680.}, {23., 1050.}}, "FullRegion" -> {{0., 1680.}, {0., 1050.}}, "PixelDimensions" -> {3360, 2100}, "BitDepth" -> 32, "Resolution" -> 144., "Scale" -> 2.}}
We can fix this by calling Rasterize
with a custom dpi setting:
img2 = Rasterize[im, ImageResolution -> 72];
ImageDimensions[img2]
{240, 240}
Answered by Chip Hurst on September 30, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP