How can I have a script automatically zoom onto a region of interest?
Show older comments
Hello,
The data to be processed by the script I am writing is in the form of arrays, which are then shown as images. The array elements are all equal to zero except where there is information, and the information will be in a different spot every time. The arrays are quite large, and the elements with info don't take up much space at all, so at the moment when the figure is displayed, there is plenty of blank space.
So, I want the script to automatically zoom onto the information area (the non-zero part of the array), no matter where the information might be in the array.
(feel free to ask for context or more information)
Cheers all!
1 Comment
Henry Kricancic
on 29 Jun 2015
Accepted Answer
More Answers (1)
Walter Roberson
on 29 Jun 2015
0 votes
Have you considered working with sparse arrays and using find() ?
For regular 2D arrays you would use regionprops() to extract the connected components; that would give you bounding boxes and even allow you to extract a copy of the sub-array in a single call. Taking the bounding box that encloses everything is a minor amount more work once you have the individual bounding boxes, with most of that work being due to the fact that bounding boxes are reported with width and height rather than start and end positions.
1 Comment
Henry Kricancic
on 29 Jun 2015
Categories
Find more on Display Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!