Skip to content

Instantly share code, notes, and snippets.

@acardona
Created December 10, 2011 04:51
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 acardona/1454607 to your computer and use it in GitHub Desktop.
Save acardona/1454607 to your computer and use it in GitHub Desktop.
A virtual image of ImgLib2 with a filled ROI
// Goal: a virtual image (a function, if you want)
// with dimensions 512, 512
// and a background of value 0
// and a ROI of dimensions 200, 200 at position 100, 100
// filled with a value 127.
// ERROR: the ROI has the right dimensions
// but its top-left is positioned with negative coordinates.
// A virtual image with a ROI filled with value 127
RandomAccessibleInterval<FloatType> img1 =
// The 'image'
Views.interval(
// The outside, with value 0
Views.extendValue(
// The ROI filled with value 127
Views.interval(
new ConstantRandomAccessible<FloatType>(new FloatType(127), 2),
// The domain of the ROI
new long[]{100, 100},
new long[]{199, 199}),
new FloatType(0)),
// The domain of the image
new long[]{0, 0},
new long[]{511, 511});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment