2
$\begingroup$

It's easy to save the coordinates of individual points, but for the life of me I can't seem to access the box's position and dimensions: {top, left, width, height}. How can I achieve this?

enter image description here

$\endgroup$
0

1 Answer 1

2
$\begingroup$

After you draw one or more selection rectangles and click away from the image they are still there suspended in a xenon mist but they are only visible if you look dead ahead use the selection tool. We can extract that data from the underlying Cell expression with this Button:

Button["Copy ImageMarkers", 
  Cases[
    NotebookRead[SelectedNotebook[]],
    _[ImageMarkers, val_] :> val,
    -1
  ] // CopyToClipboard
] // CreatePalette

First make a selection in the image:

enter image description here

Click Cancel in the Selection Tools dialog, but leave the image itself selected:

enter image description here

Click the Palette button generated earlier, then on the clipboard is:

{{Rectangle[{54., 35.}, {240., 465.}], Rectangle[{132., 329.}, {465., 488.}]}}
$\endgroup$
3
  • $\begingroup$ Thanks. Do you know how to delete just one of the rectangles? $\endgroup$
    – M.R.
    Mar 4, 2015 at 0:30
  • $\begingroup$ @M.R. Interactively or programmatically? $\endgroup$
    – Mr.Wizard
    Mar 4, 2015 at 0:32
  • $\begingroup$ Well I had hoped to create a UI tool that loads a virtual stack of images to go through this process quickly for building machine learning training metadata sets, need the bounding box for every target object in every image. So both I think! $\endgroup$
    – M.R.
    Mar 4, 2015 at 0:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.