Message Boards Message Boards

1
|
3389 Views
|
8 Replies
|
5 Total Likes
View groups...
Share
Share this post:

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

POSTED BY: Robert Nowak
8 Replies

Perhaps someone submitted this as bug/suggestion ;-) .

POSTED BY: Robert Nowak

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

POSTED BY: Sander Huisman

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}]])
POSTED BY: Robert Nowak

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.

POSTED BY: Robert Nowak

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.

POSTED BY: Sander Huisman

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[ <> ]
POSTED BY: Robert Nowak

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.

POSTED BY: Sander Huisman

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}
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract