Class RegionRequest

java.lang.Object
qupath.lib.regions.ImageRegion
qupath.lib.regions.RegionRequest

public class RegionRequest extends ImageRegion
Class for defining an image region that can also be used to request these region from an ImageServer.

In addition to the information contained within an ImageRegion, also contains the path to the image (and optionally an additional image name stored within it) and a downsample value.

Author:
Pete Bankhead
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class ImageRegion
    • createInstance

      public static RegionRequest createInstance(ImageServer<?> server)
      Create a request for the full width and height of an ImageServer, for the default plane (first z-slice, time point) and first resolution level downsample (usually 1, but not always).
      Parameters:
      server -
      Returns:
    • createInstance

      public static RegionRequest createInstance(ImageServer<?> server, double downsample)
      Create a request for the full width and height of an ImageServer, for the default plane (first z-slice, time point).
      Parameters:
      server -
      downsample -
      Returns:
    • createAllRequests

      public static List<RegionRequest> createAllRequests(ImageServer<?> server, double downsample)
      Create requests for the full width and height of an ImageServer, for all planes (z-slices and time points).
      Parameters:
      server -
      downsample -
      Returns:
    • createInstance

      public static RegionRequest createInstance(String path, double downsample, ROI roi)
      Create a request that contains the pixels of the specified ROI. This is calculated using the ROI bounding box.
      Parameters:
      path -
      downsample -
      roi -
      Returns:
    • createInstance

      public static RegionRequest createInstance(String path, double downsample, Collection<? extends ROI> rois)
      Create a request that contains the pixels of the specified ROIs. This is calculated using the ROI bounding boxes.
      Parameters:
      path -
      downsample -
      rois -
      Returns:
      Throws:
      IllegalArgumentException - if the ROIs do not all fall on the same ImagePlane.
    • createInstance

      public static RegionRequest createInstance(String path, RegionRequest request)
      Create a request that matches another request but with a different path.
      Parameters:
      path -
      request -
      Returns:
    • createInstance

      public static RegionRequest createInstance(String path, double downsample, ImageRegion region)
      Create a request corresponding to a specified ImageRegion. This may also be used to construct a request based on an existing request, but changing either the path or downsample.
      Parameters:
      path -
      downsample -
      region -
      Returns:
    • createInstance

      public static RegionRequest createInstance(String path, double downsample, int x, int y, int width, int height, int z, int t)
      Create a request for a region specified in terms of its bounding box, z-slice and time point.
      Parameters:
      path -
      downsample -
      x -
      y -
      width -
      height -
      z -
      t -
      Returns:
    • createInstance

      public static RegionRequest createInstance(String path, double downsample, int x, int y, int width, int height, ImagePlane plane)
      Create a request for a region specified in terms of its bounding box and ImagePlane.
      Parameters:
      path -
      downsample -
      x -
      y -
      width -
      height -
      plane -
      Returns:
    • createInstance

      public static RegionRequest createInstance(String path, double downsample, int x, int y, int width, int height)
      Create a request for a region specified in terms of its bounding box, using the first z-slice and time point.
      Parameters:
      path -
      downsample -
      x -
      y -
      width -
      height -
      Returns:
    • overlapsRequest

      public boolean overlapsRequest(RegionRequest request)
      Returns true if the region specified by this request overlaps with that of another request. The test includes insuring that they refer to the same image by checking the paths are the same.
      Parameters:
      request -
      Returns:
    • getPath

      public String getPath()
      Get the requested ImageServer path, used as an identifier.
      Returns:
      See Also:
    • getDownsample

      public double getDownsample()
      Get the requested downsample factor, defining the resolution at which pixels should be returned.
      Returns:
    • intersect2D

      public RegionRequest intersect2D(ImageRegion region)
      Intersect to the specified 2D region, ignoring z and t.
      Parameters:
      region - the region defining the x, y, width and height of the maximum permitted bounding box.
      Returns:
      the clipped RegionRequest, which may be this if no clipping is required.
    • intersect2D

      public RegionRequest intersect2D(int x, int y, int width, int height)
      Intersect to the specified 2D region.
      Parameters:
      x - x-coordinate of the second region's bounding box
      y - y-coordinate of the second region's bounding box
      width - width of the second region's bounding box
      height - height of the second region's bounding box
      Returns:
      the clipped RegionRequest, which may be this if no clipping is required.
    • updateZ

      public RegionRequest updateZ(int z)
      Create a RegionRequest equivalent to this one with the updated z value.
      Parameters:
      z - requested z position
      Returns:
      RegionRequest with the specified z value (may be this object unchanged).
    • updateT

      public RegionRequest updateT(int t)
      Create a RegionRequest equivalent to this one with the updated t value.
      Parameters:
      t - requested t position
      Returns:
      RegionRequest with the specified t value (may be this object unchanged).
    • updateDownsample

      public RegionRequest updateDownsample(double downsample)
      Create a RegionRequest equivalent to this one with the updated downsample value.
      Parameters:
      downsample - requested downsample position
      Returns:
      RegionRequest with the specified downsample value (may be this object unchanged).
    • updatePath

      public RegionRequest updatePath(String path)
      Create a RegionRequest equivalent to this one with the updated path.
      Parameters:
      path - requested path position
      Returns:
      RegionRequest with the specified path value (may be this object unchanged).
    • translate

      public RegionRequest translate(int dx, int dy)
      Create a RegionRequest equivalent to this one with the x and y coordinates updated by translation.
      Parameters:
      dx - value to add to the x coordinate
      dy - value to add to the y coordinate
      Returns:
      RegionRequest with the specified path value (may be this object unchanged).
    • pad2D

      public RegionRequest pad2D(int xPad, int yPad)
      Add symmetric padding to the x and y dimensions of a request.
      Parameters:
      xPad - padding to add along the x dimension; the width will be adjusted by xPad * 2
      yPad - padding to add along the y dimension; the height will be adjusted by yPad * 2
      Returns:
      RegionRequest with the specified padding (may be this object unchanged if the padding is zero).
    • pad2D

      public RegionRequest pad2D(Padding padding)
      Add symmetric padding to the x and y dimensions of a request.
      Parameters:
      padding - padding to add
      Returns:
      RegionRequest with the specified padding (may be this object unchanged if the padding is zero).
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ImageRegion
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class ImageRegion