|
ICY Version 1.0.1.0
|
public class GenerateImageOfDifferentType extends Plugin implements PluginImageAnalysis { @Override public void compute() { // generate a FLOAT image ( 1 band ) { // create the image object IcyBufferedImage image = new IcyBufferedImage(256, // width 256, // height 1, // number of channels (note that channel is same as color components or color // band) TypeUtil.TYPE_FLOAT); float[] dataBuffer = image.getDataXYAsFloat(0); // get a direct reference to first // component data // fill data for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) dataBuffer[x + y * 256] = (float) (Math.random() - 0.5); // directly assign to // buffer // notify to icy that data has changed to refresh internal state and display image.dataChanged(); // create a sequence Sequence sequence = new Sequence("Float Image", image); // Create a viewer to watch the sequence. addSequence(sequence); } // generate a BYTE image ( 1 band ) { // create the image object IcyBufferedImage image = new IcyBufferedImage(256, // width 256, // height 1, // number of channels (note that channel is same as color components or color // band) TypeUtil.TYPE_BYTE); byte[] dataBuffer = image.getDataXYAsByte(0); // get a direct reference to first // component data // fill data for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) dataBuffer[x + y * 256] = (byte) (x * y); // directly assign to buffer // notify to icy that data has changed to refresh internal state and display image.dataChanged(); // create a sequence Sequence sequence = new Sequence("Byte Image", image); // Create a viewer to watch the sequence. addSequence(sequence); } // generate a INT image ( 1 band ) { // create the image object IcyBufferedImage image = new IcyBufferedImage(256, // width 256, // height 1, // number of channels (note that channel is same as color components or color // band) TypeUtil.TYPE_INT); int[] dataBuffer = image.getDataXYAsInt(0); // get a direct reference to first component // data // fill data for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) dataBuffer[x + y * 256] = (int) (x * y); // directly assign to buffer // notify to icy that data has changed to refresh internal state and display image.dataChanged(); // create a sequence Sequence sequence = new Sequence("Int Image", image); // Create a viewer to watch the sequence. addSequence(sequence); } // generate a USHORT image ( 1 band ) { // create the image object IcyBufferedImage image = new IcyBufferedImage(256, // width 256, // height 1, // number of channels (note that channel is same as color components or color // band) TypeUtil.TYPE_SHORT, false // set as USHORT ( unsigned ) ); short[] dataBuffer = image.getDataXYAsShort(0); // get a direct reference to first // component data // fill data for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) dataBuffer[x + y * 256] = (short) (x * y); // directly assign to buffer // notify to icy that data has changed to refresh internal state and display image.dataChanged(); // create a sequence Sequence sequence = new Sequence("Short Image", image); // Create a viewer to watch the sequence. addSequence(sequence); } // generate a SHORT image ( 1 band ) { // create the image object IcyBufferedImage image = new IcyBufferedImage(256, // width 256, // height 1, // number of channels (note that channel is same as color components or color // band) TypeUtil.TYPE_SHORT, true // set as SHORT ( signed ) ); short[] dataBuffer = image.getDataXYAsShort(0); // get a direct reference to first // component data // fill data for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) dataBuffer[x + y * 256] = (short) (x * y); // directly assign to buffer // notify to icy that data has changed to refresh internal state and display image.dataChanged(); // create a sequence Sequence sequence = new Sequence("Unsigned Short Image", image); // Create a viewer to watch the sequence. addSequence(sequence); } // generate a DOUBLE image ( 1 band ) { // create the image object IcyBufferedImage image = new IcyBufferedImage(256, // width 256, // height 1, // number of channels (note that channel is same as color components or color // band) TypeUtil.TYPE_DOUBLE); double[] dataBuffer = image.getDataXYAsDouble(0); // get a direct reference to first // component data // fill data for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) dataBuffer[x + y * 256] = (double) (Math.random() - 0.5); // directly assign to // buffer // notify to icy that data has changed to refresh internal state and display image.dataChanged(); // create a sequence Sequence sequence = new Sequence("Double Image", image); // Create a viewer to watch the sequence. addSequence(sequence); } } }
1.7.3