Confusion with Dimensions property in ImageMeasurements

Hi everbody

There seems to be some discrepancy with the “Dimensions” property of ImageMeasurements[ ].

RandomImage[1, {200, 100}];
ImageMeasurements[%, "Dimensions"]
ImageDimensions[%%]

-> {100, 200}

-> {200, 100}

As an image based function I would expect “Dimensions” to return the ImageDimensions in {width, height) order, but instead it gives the Dimensions of the underlying array.

Bug or feature?

Robert

Good point! Looks indeed to be Dimensions[ImageData[img]].
ImageMeasurements calls internally: Image`ImageInformation:

Image`ImageInformation[RandomImage[1, {200, 100}], "Dimensions"]

But that function is compiled code and can not be looked into.

Since it picks up also the dimensions of the channels, I guess it is indeed just Dimensions[ImageData[…]]:

RandomImage[1, {100, 200}, ColorSpace -> "RGB"]
ImageMeasurements[%, "Dimensions"]

{200, 100, 3}

Still somehow not satisfying. For channels we have:

ImageMeasurements[%, "Channels"]

Perhaps it would be the best solution if:

ImageMeasurements[imge, "ImageDimensions"]

Would be supported as well, but:

ImageMeasurements::invprop: ImageDimensions is not a known image measurements property.

Why the topic?

I would like to gather some image information in a nice Dataset[ ] format like this:

ImageMeasurements[image, {"Channels", "Transparency", "ColorSpace", 
  "DataType", "Dimensions", "MinIntensity", "MaxIntensity", 
  "TotalIntensity", "MeanIntensity", 
  "StandardDeviationIntensity"}, "Dataset"]

-> Dataset[ <> ]

Somehow the parts don’t fit consistently together.

RandomImage[1, {200, 100}];
ComponentMeasurements[%, "Dimensions"]

Out[1]= {1 -> {200, 100}}

Unfortunately no “Channels” property available for ComponentMeasurements.

Yeah Indeed, it seems perhaps an oversight… As you said, providing both Dimensions and ImageDimensions properties would avoid confusion…

You could submit this as bug/suggestion.

Just for fun a small fix:

ImageMeasurements[
  image, {"Channels", "Transparency", "ColorSpace", "DataType", 
   "Dimensions", "MinIntensity", "MaxIntensity", "TotalIntensity", 
   "MeanIntensity", "StandardDeviationIntensity"}, "Dataset"] //
 (d \[Function] 
   ReplacePart[d, "Dimensions" -> Normal@d["Dimensions", {2, 1}]])

Without going in detail, I just wanted to say that this will be resolved in the next version…

Perhaps someone submitted this as bug/suggestion :wink: .