It is easy to see that NumericArray is a construct underlying Image:
img = Import["ExampleData/coneflower.jpg", IncludeMetaInformation -> None];
ResourceFunction["ShortInputForm"][img]
At the same time, unlike Image, we can directly manipulate NumericArray using such handy functions as Part, Flatten etc. Of course, we can convert Image into a packed array using ImageData, but resulting array will occupy much more memory than the original image:
ByteCount /@ {img, ImageData[img, "Byte"]}
{55248, 407016}
The function ShortInputForm uses a hack identical to the Nucleus function by Carl Woll for accessing the internal structure of atomic objects. This hack allows extracting the NumericArray:
Nucleus[img][[1]]
But of course it would be much better to have a non-hackish way to do this, which wouldn't depend on undocumented details of implementation of LinkWrite and LinkRead, and hopefully would also be more efficient.
Hence my question: What is the idiomatic way to extract NumericArray from Image?


NoEntryQobject you can grab its parts all you want viaReplace[img, _[x_, ___] :> x], but that's hardly idiomatic is it? I would think you are unlikely to find a builtin solution that doesn't have the words "Private" or "Internal" in the function name. – Jason B. May 23 '22 at 19:50Internal`context. At least, do not define a special hackish function for such a basic task... – Alexey Popkov May 23 '22 at 19:52Replace[img, _[x_, ___] :> x]could be an acceptable solution, thank you! You can post this as an answer. – Alexey Popkov May 23 '22 at 19:56Replacemethod I think is a bit heavy handed so I posted a couple of other methods. – Jason B. May 23 '22 at 20:48