Java Code Examples for net.imglib2.type.numeric.ARGBType#blue()

The following examples show how to use net.imglib2.type.numeric.ARGBType#blue() . 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: ARGBCompositeAlphaAdd.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void compose(final ARGBType a, final ARGBType b)
{
	final int argbA = a.get();
	final int argbB = b.get();

	final int rA = ARGBType.red(argbA);
	final int rB = ARGBType.red(argbB);
	final int gA = ARGBType.green(argbA);
	final int gB = ARGBType.green(argbB);
	final int bA = ARGBType.blue(argbA);
	final int bB = ARGBType.blue(argbB);

	final double aA = ARGBType.alpha(argbA) / 255.0;
	final double aB = ARGBType.alpha(argbB) / 255.0;
	//		final double aB = ( rB == gB || gB == bB ) ? ARGBType.alpha( argbB ) / 255.0 : ARGBType.alpha( argbB )
	// / 255.0 * 0.125;

	final double aTarget = aA + aB - aA * aB;

	final int rTarget = Math.min(255, (int) Math.round(rA + rB * aB));
	final int gTarget = Math.min(255, (int) Math.round(gA + gB * aB));
	final int bTarget = Math.min(255, (int) Math.round(bA + bB * aB));

	a.set(ARGBType.rgba(rTarget, gTarget, bTarget, (int) (aTarget * 255)));
}
 
Example 2
Source File: Colors.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public static Color toColor(final int argb)
{
	final int r = ARGBType.red(argb);
	final int g = ARGBType.green(argb);
	final int b = ARGBType.blue(argb);
	final int a = ARGBType.alpha(argb);
	return Color.rgb(r, g, b, a / 255.0);
}
 
Example 3
Source File: ARGBColorConverter.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private void update()
{
	final double scale = 1.0 / (max.get() - min.get());
	final int    value = color.get().get();
	A = (int) Math.min(Math.max(Math.round(255 * alphaProperty().get()), 0), 255);
	scaleR = ARGBType.red(value) * scale;
	scaleG = ARGBType.green(value) * scale;
	scaleB = ARGBType.blue(value) * scale;
	black = ARGBType.rgba(0, 0, 0, A);
}
 
Example 4
Source File: ARGBCompositeColorConverter.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private void update() {
	A = (int) Math.min(Math.max(Math.round(255 * alphaProperty().get()), 0), 255);
	for (int channel = 0; channel < numChannels; ++channel) {
		final double scale = 1.0 / (max[channel].get() - min[channel].get());
		final int value = color[channel].get().get();
		final double a = channelAlpha[channel].get();
		scaleR[channel] = ARGBType.red(value) * scale * a;
		scaleG[channel] = ARGBType.green(value) * scale * a;
		scaleB[channel] = ARGBType.blue(value) * scale * a;
	}
	LOG.debug("Updated red   scales to {}", scaleR);
	LOG.debug("Updated green scales to {}", scaleG);
	LOG.debug("Updated blue  scales to {}", scaleB);
}
 
Example 5
Source File: MaximumProjectorARGB.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void accumulate( final Cursor< ? extends ARGBType >[] accesses, final ARGBType target )
{
	int aMax = 0, rMax = 0, gMax = 0, bMax = 0;
	for ( final Cursor< ? extends ARGBType > access : accesses )
	{
		final int value = access.get().get();
		final int a = ARGBType.alpha( value );
		final int r = ARGBType.red( value );
		final int g = ARGBType.green( value );
		final int b = ARGBType.blue( value );
		
		aMax = Math.max( aMax, a );
		rMax = Math.max( rMax, r );
		gMax = Math.max( gMax, g );
		bMax = Math.max( bMax, b );
	}
	
	if ( aMax > 255 )
		aMax = 255;
	if ( rMax > 255 )
		rMax = 255;
	if ( gMax > 255 )
		gMax = 255;
	if ( bMax > 255 )
		bMax = 255;
	
	
	target.set( ARGBType.rgba( rMax, gMax, bMax, aMax ) );
}
 
Example 6
Source File: ARGBCompositeAlphaYCbCr.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void compose(final ARGBType a, final ARGBType b)
{
	final int argbA = a.get();
	final int argbB = b.get();

	final double rA = ARGBType.red(argbA) / 255.0;
	final double rB = ARGBType.red(argbB) / 255.0;
	final double gA = ARGBType.green(argbA) / 255.0;
	final double gB = ARGBType.green(argbB) / 255.0;
	final double bA = ARGBType.blue(argbA) / 255.0;
	final double bB = ARGBType.blue(argbB) / 255.0;

	final double aA = ARGBType.alpha(argbA) / 255.0;
	final double aB = ARGBType.alpha(argbB) / 255.0;
	//		final double aB = ( rB == gB || gB == bB ) ? ARGBType.alpha( argbB ) / 255.0 * 0.5 : ARGBType.alpha(
	// argbB ) / 255.0 * 0.125;

	final double aTarget = aA + aB - aA * aB;

	final double yA  = rgb2y(rA, gA, bA);
	final double cbA = rgb2cb(rA, gA, bA);
	final double crA = rgb2cr(rA, gA, bA);

	final double cbB = rgb2cb(rB, gB, bB);
	final double crB = rgb2cr(rB, gB, bB);

	final double aBInv = 1.0 - aB;

	final double cbTarget = cbA * aBInv + cbB * aB;
	final double crTarget = crA * aBInv + crB * aB;

	final double rTarget = ycbcr2r(yA, cbTarget, crTarget);
	final double gTarget = ycbcr2g(yA, cbTarget, crTarget);
	final double bTarget = ycbcr2b(yA, cbTarget, crTarget);

	a.set(ARGBType.rgba(
			Math.max(0, Math.min(255, (int) Math.round(rTarget * 255))),
			Math.max(0, Math.min(255, (int) Math.round(gTarget * 255))),
			Math.max(0, Math.min(255, (int) Math.round(bTarget * 255))),
			(int) (aTarget * 255)
	                   ));
}
 
Example 7
Source File: AveragingProjectorARGB.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void accumulate( final Cursor< ? extends ARGBType >[] accesses, final ARGBType target )
{
	int aSum = 0, rSum = 0, gSum = 0, bSum = 0;
	int nonZeroAccesses = 0;
	for ( final Cursor< ? extends ARGBType > access : accesses )
	{
		final int value = access.get().get();
		final int a = ARGBType.alpha( value );
		final int r = ARGBType.red( value );
		final int g = ARGBType.green( value );
		final int b = ARGBType.blue( value );
		
		if (a>0 || r>0 || g>0 || b>0)
			nonZeroAccesses++;
		
		aSum += a;
		rSum += r;
		gSum += g;
		bSum += b;
	}
	
	nonZeroAccesses = nonZeroAccesses > 0 ? nonZeroAccesses : 1;
	
	aSum /= nonZeroAccesses;
	rSum /= nonZeroAccesses;
	gSum /= nonZeroAccesses;
	bSum /= nonZeroAccesses;
	
	if ( aSum > 255 )
		aSum = 255;
	if ( rSum > 255 )
		rSum = 255;
	if ( gSum > 255 )
		gSum = 255;
	if ( bSum > 255 )
		bSum = 255;
	
	
	target.set( ARGBType.rgba( rSum, gSum, bSum, aSum ) );
}