Java Code Examples for ij.process.ShortProcessor#getPixels()

The following examples show how to use ij.process.ShortProcessor#getPixels() . 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: Utils.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
/** A method that circumvents the findMinAndMax when creating a float processor from an existing processor.  Ignores color calibrations and does no scaling at all. */
static public final FloatProcessor fastConvertToFloat(final ShortProcessor ip) {
	final short[] pix = (short[])ip.getPixels();
	final float[] data = new float[pix.length];
	for (int i=0; i<pix.length; i++) data[i] = pix[i]&0xffff;
	final FloatProcessor fp = new FloatProcessorT2(ip.getWidth(), ip.getHeight(), data, ip.getColorModel(), ip.getMin(), ip.getMax());
	return fp;
}
 
Example 2
Source File: ExportBestFlatImage.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
protected FloatProcessor convertToFloat( final ShortProcessor sp )
{
	final short[] pixS = (short[]) sp.getPixels();
	loader.releaseToFit( pixS.length * 4 );
	final float[] pixF = new float[pixS.length];

	for ( int i=0; i<pixS.length; ++i) {
		pixF[i] = pixS[i] & 0xffff;
	}

	return new FloatProcessor( sp.getWidth(), sp.getHeight(), pixF );
}
 
Example 3
Source File: ImagePlusMatConverter.java    From IJ-OpenCV with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Duplicates {@link ShortProcessor} to the corresponding OpenCV image of
 * type {@link Mat}.
 *
 * @param sp The {@link ShortProcessor} to be converted
 * @return The OpenCV image (of type {@link Mat})
 */
public static Mat toMat(ShortProcessor sp) {
    final int w = sp.getWidth();
    final int h = sp.getHeight();
    final short[] pixels = (short[]) sp.getPixels();
    return new Mat(h, w, opencv_core.CV_16UC1, new ShortPointer(pixels));
}