Last active
July 21, 2016 14:47
-
-
Save bogovicj/cb69d9ea04df32005b9e8ad8005e2268 to your computer and use it in GitHub Desktop.
Masking a RandomAccessibleInterval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T extends RealType<T>, M extends RealType<M>> void maskToValue( | |
RandomAccessibleInterval<T> img, | |
RandomAccessibleInterval<M> mask, | |
RandomAccessibleInterval<T> out, | |
T val ) | |
{ | |
Cursor< M > maskC = Views.flatIterable( mask ).cursor(); | |
RandomAccess< T > ira = img.randomAccess(); | |
RandomAccess< T > ora = out.randomAccess(); | |
while( maskC.hasNext() ) | |
{ | |
maskC.fwd(); | |
ira.setPosition( maskC ); | |
ora.setPosition( maskC ); | |
if( maskC.get().getRealDouble() > 0 ) | |
ora.get().set( ira.get() ); | |
else | |
ora.get().set( val ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment