# using HighlightImage on a large image causes a display error

I get a display error when using the HighlightImage function on a large image (about 6000 x 10000 pixels). This error occurs in Mathematica versions 10.4, 11.0, and 11.1. I am running 64bit Win 8.1pro and have a NVIDIA GeForce GTX 770 installed. Display drivers are up to date (382.53). The error persists after a clean install of the display drivers.

This line works fine (imgfeatures is a binary image representing the skeletonized content of the original image):

imgres = HighlightImage[img, imgfeatures];


and I can even see the output using:

imgres


But when I try to do something with the image like:

ImageResize[imgres,1000]


Mathematica (and shortly afterwards Windows) freezes, then the screen flashes and an error message pops up: "display driver stopped responding and has recovered"

However, everything works well when I use a much smaller version of that image (about 2000 x 6000 pixels). Any ideas?

EDIT

Here is some code that produces the error:

img = Import["https://i.stack.imgur.com/Bgxr5.png"];

(*padding to 2199 x 6199 pixels*)
bigimg = ImagePad[img, {{1000, 1000}, {3000, 3000}}, "Reflected"];
(*the resulting image is shown*)
imgres = HighlightImage[bigimg, bigimg]
(*resizing works*)
ImageResize[imgres, 1000 ]

(*padding to 6199 x 6199 pixels*)
bigimg = ImagePad[img, {{3000, 3000}, {3000, 3000}}, "Reflected"];
(*the resulting image is shown*)
imgres = HighlightImage[bigimg, bigimg]
(*resizing does not work: the display error occurs and a blank image*)
(*with the dimensions of 1000 x1000 pixels is shown*)
ImageResize[imgres, 1000 ]

(*padding to 6199 x 12199 pixels*)
bigimg = ImagePad[img, {{3000, 3000}, {6000, 6000}}, "Reflected"];
(*the resulting image is shown*)
imgres = HighlightImage[bigimg, bigimg]
(*resizing does not work: the display error **DOES NOT** occur and*)
(*a blank image with the dimensions of 1000 x **1968** pixels is shown*)
ImageResize[imgres, 1000 ]

(*padding to 12199 x 12199 pixels*)
bigimg = ImagePad[img, {{6000, 6000}, {6000, 6000}}, "Reflected"];
(*the resulting image is shown*)
imgres = HighlightImage[bigimg, bigimg]
(*resizing does not work: the display error **DOES NOT** occur, a blank*)
(*image is shown; Mathematica shows an error:*)
ImageResize[imgres, 1000 ]
ImageDimensions::imginv: Expecting an image or graphics instead of {12199,12199}.

• – Kuba Jun 14 '17 at 11:15