Hi,
There’s a easier bit and a much more difficult bit to this answer.
The easier bit is getting the bounding box. If you create an annotation for the tissue (e.g. manually with a drawing tool, with an ImageJ macro, or with Simple Tissue Detection) then you can get the bounding box like this:
def selected = getSelectedObject() // If the object is selected...
def roi = selected.getROI()
int x = roi.getBoundsX()
int y = roi.getBoundsY()
int width = roi.getBoundsWidth()
int height = roi.getBoundsHeight()
print([x, y, width, height])
Now, reloading only that part of the image within QuPath is difficult. Currently, you’d need to crop the image and saved a new cropped file. QuPath doesn’t give you a way to do that for a whole slide image; so you’d need to crop and write the new image some other way.
A QuPath-based alternative would require that you write a custom ImageServer that wraps around your existing ImageServer that QuPath uses to request pixels from the whole slide, and which also knows about the crop bounds. This custom ImageServer would then perform all the coordinate transforms required to ‘trick’ QuPath into thinking that the cropped image is actually a whole slide (i.e. subtracting the x, y coordinates of the bounding box from any pixel request, and setting the image width and height according to those of the bounding box).
This should be technically possible, but it would take some work to write the custom ImageServer and you'd need to be careful not to thwart QuPath's built-in method of caching image regions. You would also somehow need tell QuPath to use the cropped bounds whenever you reopen the image in the future. This could require a modification to the core QuPath code, or else some more custom trickery that takes you deeper into how QuPath is working than you might want to go.
Given the effort that would be required, I really wouldn’t advise trying this unless it is absolutely necessary. Rather, I’d try to find something simpler. For example, if you are happy with coding you could try writing a script that sets the displayed image magnification and location so that the tissue bounding box is fit into the center of the viewer at the maximum size that contains all the tissue. The rest of the image will still be there... just outside the visible bounds of the viewer.
Hope this helps,
Pete