1
$\begingroup$

A convenient way to check the results of ComonentMeasurements is to show the results using Epilog. However, one of these features appears to have changed behavior in Version 12.

Usually this is used for an x-ray, CT image, or Ultrasound. For example localizing the center of the active volume in an ion chamber which would be placed in this cavity: Image of Slab with Ion Chamber Hole

For this example, i am just creating an image that shows the behavior.

Here is an example of using the ComponentMeasurements function to identify a simple disk in a black background and display the results of this function using HighlightImage and Epilog (which one might expect to be the same).

UseImage=Image[Graphics[{Black,Rectangle[{-10,-10},{10,10}],White,Disk[{0,0},1]}],ImageSize->200];
UseComp=ComponentMeasurements[UseImage,{"Centroid","Circularity","EquivalentDiskRadius"}][[All,2]];
UseComp=Select[UseComp,(0.9<#[[2]]<1.&)];
Grid[{{"Version 12",SpanFromLeft},{"HighlightImage","Epilog"},{HighlightImage[UseImage
,{Red,(Disk[#[[1]],#[[3]]]&)/@UseComp}
,ImageSize->200
]
,Show[UseImage
,Epilog->{Red,(Disk[#[[1]],#[[3]]]&)/@UseComp}
,ImageSize->200
]
}}]

Prior to version 12, the ComponentMeasurements appeared to give the location of the components in units of something that matched the image.

Behavior in Version 11

In Version 12.1.1.0, the display functions have changed (larger images?) as has the behavior of Epilog.

Behavior in Version 12

Is there and easy way to allow a uniform behavior between HighlightImage and Epilog?

$\endgroup$
3
  • 4
    $\begingroup$ The path of least resistance is to swap out your use of Image[Graphics[...], ImageSize->200] for Rasterize[Graphics[...], ImageSize->200, ImageResolution->72]. This restores the assumption that 1 pixel = 1 point. Points are the native unit for ImageSize in the FrontEnd and are almost never equivalent to 1 pixel in 12.1+. $\endgroup$
    – ihojnicki
    Nov 16, 2020 at 18:51
  • $\begingroup$ Thanks, you answered the question, but i asked it badly. The Image is actually an imported image - i should have made that clear in the question. $\endgroup$
    – xsk8rat
    Nov 16, 2020 at 19:22
  • $\begingroup$ But that does work: Image[Import[filename],ImageResolution->72]. Thank you! $\endgroup$
    – xsk8rat
    Nov 16, 2020 at 19:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.