Skip to content

Instantly share code, notes, and snippets.

@ctrueden
Last active May 21, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrueden/5143f1511cc21b8e8f64c1626e72962c to your computer and use it in GitHub Desktop.
Save ctrueden/5143f1511cc21b8e8f64c1626e72962c to your computer and use it in GitHub Desktop.
Import a cropped region of a 2D image using SCIFIO
#@ DatasetIOService dio
#@ File imageFile
#@ long x
#@ long y
#@ long width
#@ long height
#@output Dataset dataset
from io.scif.config import SCIFIOConfig
from io.scif.img import ImageRegion, Range
from net.imagej.axis import Axes
config = SCIFIOConfig()
xRange = Range(x, x + width - 1)
yRange = Range(y, y + height - 1)
region = {Axes.X: xRange, Axes.Y: yRange}
config.imgOpenerSetRegion(ImageRegion(region))
dataset = dio.open(imageFile.getAbsolutePath(), config)
@ctrueden
Copy link
Author

Originally posted to this Image.sc Forum thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment