Java Code Examples for mpicbg.imglib.cursor.LocalizableByDimCursor#getPosition()

The following examples show how to use mpicbg.imglib.cursor.LocalizableByDimCursor#getPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Entropy.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
private static final void updateBinNegative(final int[] absFreq, final int histogramBins, final int x, final int y, final int z, final LocalizableByDimCursor<FloatType> cursor)
{
	// compute bins
	final int mx = x - cursor.getPosition( 0 );
	final int my = y - cursor.getPosition( 1 );
	final int mz = z - cursor.getPosition( 2 );
	
	cursor.move( mx, 0 );
	cursor.move( my, 1 );
	cursor.move( mz, 2 );
	
	int bin = (int) (cursor.getType().get() * histogramBins);

	cursor.move( -mx, 0 );
	cursor.move( -my, 1 );
	cursor.move( -mz, 2 );

	// for the case of value being exactly 1
	if (bin >= histogramBins) bin = histogramBins - 1;
	if (bin < 0) bin = 0;

	absFreq[bin]--;			
}
 
Example 2
Source File: Entropy.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
private static final void updateBinPositive(final int[] absFreq, final int histogramBins, final int x, final int y, final int z, final LocalizableByDimCursor<FloatType> cursor)
{
	// compute bins
	final int mx = x - cursor.getPosition( 0 );
	final int my = y - cursor.getPosition( 1 );
	final int mz = z - cursor.getPosition( 2 );
	
	cursor.move( mx, 0 );
	cursor.move( my, 1 );
	cursor.move( mz, 2 );
	
	int bin = (int) (cursor.getType().get() * histogramBins);

	cursor.move( -mx, 0 );
	cursor.move( -my, 1 );
	cursor.move( -mz, 2 );

	// for the case of value being exactly 1
	if (bin >= histogramBins) bin = histogramBins - 1;
	if (bin < 0) bin = 0;

	absFreq[bin]++;			
}