TransWikia.com

Mathematica 12 HighlightImage doubles image dimensions ! Bug?

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.

enter image description here

One Answer

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

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