001: /*
002: * $RCSfile: SubtractOpImage.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:56:45 $
010: * $State: Exp $
011: */
012: package com.sun.media.jai.opimage;
013:
014: import java.awt.Rectangle;
015: import java.awt.image.DataBuffer;
016: import java.awt.image.Raster;
017: import java.awt.image.RenderedImage;
018: import java.awt.image.SampleModel;
019: import java.awt.image.WritableRaster;
020: import java.util.Map;
021: import javax.media.jai.ImageLayout;
022: import javax.media.jai.OpImage;
023: import javax.media.jai.PointOpImage;
024: import javax.media.jai.RasterAccessor;
025: import javax.media.jai.RasterFormatTag;
026: import javax.media.jai.RasterFactory;
027: import com.sun.media.jai.util.ImageUtil;
028: import com.sun.media.jai.util.JDKWorkarounds;
029:
030: /// import com.sun.media.jai.test.OpImageTester;
031:
032: /**
033: * An <code>OpImage</code> implementing the "Subtract" operation as
034: * described in <code>javax.media.jai.operator.SubtractDescriptor</code>.
035: *
036: * <p>This <code>OpImage</code> subtracts the pixel values of the second
037: * source image from the first source images on a per-band basis. In case
038: * the two source images have different number of bands, the number of
039: * bands for the destination image is the smaller band number of the two
040: * source images. That is
041: * <code>dstNumBands = Math.min(src1NumBands, src2NumBands)</code>.
042: * In case the two source images have different data types, the data type
043: * for the destination image is the higher data type of the two source
044: * images.
045: *
046: * <p>The value of the pixel (x, y) in the destination image is defined as:
047: * <pre>
048: * for (b = 0; b < numBands; b++) {
049: * dst[y][x][b] = src1[y][x][b] - src2[y][x][b];
050: * }
051: * </pre>
052: *
053: * <p>If the result of the subtraction overflows/underflows the
054: * maximum/minimum value supported by the destination image, then it
055: * will be clamped to the maximum/minimum value respectively. The
056: * data type <code>byte</code> is treated as unsigned, with maximum
057: * value as 255 and minimum value as 0.
058: *
059: * @see javax.media.jai.operator.SubtractDescriptor
060: * @see SubtractCRIF
061: *
062: */
063: final class SubtractOpImage extends PointOpImage {
064:
065: /* Source 1 band increment */
066: private int s1bd = 1;
067:
068: /* Source 2 band increment */
069: private int s2bd = 1;
070:
071: /**
072: * Constructs an <code>SubtractOpImage</code>.
073: *
074: * <p>The <code>layout</code> parameter may optionally contains the
075: * tile grid layout, sample model, and/or color model. The image
076: * dimension is determined by the intersection of the bounding boxes
077: * of the two source images.
078: *
079: * <p>The image layout of the first source image, <code>source1</code>,
080: * is used as the fall-back for the image layout of the destination
081: * image. Any layout parameters not specified in the <code>layout</code>
082: * argument are set to the same value as that of <code>source1</code>.
083: *
084: * @param source1 The first source image.
085: * @param source2 The second source image.
086: * @param layout The destination image layout.
087: */
088: public SubtractOpImage(RenderedImage source1,
089: RenderedImage source2, Map config, ImageLayout layout) {
090: super (source1, source2, layout, config, true);
091: // Get the source band counts.
092: int numBands1 = source1.getSampleModel().getNumBands();
093: int numBands2 = source2.getSampleModel().getNumBands();
094:
095: // Handle the special case of subtracting from each band of an N-band
096: // image a single-band image.
097: int numBandsDst;
098: if (layout != null
099: && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
100: SampleModel sm = layout.getSampleModel(null);
101: numBandsDst = sm.getNumBands();
102:
103: // The second source must be single-banded and the first must
104: // be multi-banded.
105: if (numBandsDst > 1
106: && ((numBands1 > 1 && numBands2 == 1) || (numBands1 == 1 && numBands2 > 1))) {
107: // Clamp the destination band count to the number of
108: // bands in the multi-band source.
109: numBandsDst = Math.min(Math.max(numBands1, numBands2),
110: numBandsDst);
111:
112: // Create a new SampleModel if necessary.
113: if (numBandsDst != sampleModel.getNumBands()) {
114: sampleModel = RasterFactory
115: .createComponentSampleModel(sm, sampleModel
116: .getTransferType(), sampleModel
117: .getWidth(), sampleModel
118: .getHeight(), numBandsDst);
119:
120: if (colorModel != null
121: && !JDKWorkarounds.areCompatibleDataModels(
122: sampleModel, colorModel)) {
123: colorModel = ImageUtil.getCompatibleColorModel(
124: sampleModel, config);
125: }
126: }
127:
128: // Set the source band increments.
129: s1bd = numBands1 == 1 ? 0 : 1;
130: s2bd = numBands2 == 1 ? 0 : 1;
131: }
132: }
133:
134: // Set flag to permit in-place operation.
135: permitInPlaceOperation();
136: }
137:
138: /**
139: * Subtracts the pixel values of two source images within a specified
140: * rectangle.
141: *
142: * @param sources Cobbled sources, guaranteed to provide all the
143: * source data necessary for computing the rectangle.
144: * @param dest The tile containing the rectangle to be computed.
145: * @param destRect The rectangle within the tile to be computed.
146: */
147: protected void computeRect(Raster[] sources, WritableRaster dest,
148: Rectangle destRect) {
149: // Retrieve format tags.
150: RasterFormatTag[] formatTags = getFormatTags();
151:
152: RasterAccessor s1 = new RasterAccessor(sources[0], destRect,
153: formatTags[0], getSource(0).getColorModel());
154: RasterAccessor s2 = new RasterAccessor(sources[1], destRect,
155: formatTags[1], getSource(1).getColorModel());
156: RasterAccessor d = new RasterAccessor(dest, destRect,
157: formatTags[2], getColorModel());
158:
159: if (d.isBinary()) {
160: byte[] src1Bits = s1.getBinaryDataArray();
161: byte[] src2Bits = s2.getBinaryDataArray();
162: byte[] dstBits = d.getBinaryDataArray();
163:
164: int length = dstBits.length;
165: for (int i = 0; i < length; i++) {
166: // "Subtract" is equivalent to the following
167: // when -1 is clamped to 0.
168: dstBits[i] = (byte) (src1Bits[i] & (byte) (~(src2Bits[i])));
169: }
170:
171: d.copyBinaryDataToRaster();
172:
173: return;
174: }
175:
176: switch (d.getDataType()) {
177: case DataBuffer.TYPE_BYTE:
178: computeRectByte(s1, s2, d);
179: break;
180: case DataBuffer.TYPE_USHORT:
181: computeRectUShort(s1, s2, d);
182: break;
183: case DataBuffer.TYPE_SHORT:
184: computeRectShort(s1, s2, d);
185: break;
186: case DataBuffer.TYPE_INT:
187: computeRectInt(s1, s2, d);
188: break;
189: case DataBuffer.TYPE_FLOAT:
190: computeRectFloat(s1, s2, d);
191: break;
192: case DataBuffer.TYPE_DOUBLE:
193: computeRectDouble(s1, s2, d);
194: break;
195: }
196:
197: if (d.needsClamping()) {
198: d.clampDataArrays();
199: }
200:
201: d.copyDataToRaster();
202: }
203:
204: private void computeRectByte(RasterAccessor src1,
205: RasterAccessor src2, RasterAccessor dst) {
206: int s1LineStride = src1.getScanlineStride();
207: int s1PixelStride = src1.getPixelStride();
208: int[] s1BandOffsets = src1.getBandOffsets();
209: byte[][] s1Data = src1.getByteDataArrays();
210:
211: int s2LineStride = src2.getScanlineStride();
212: int s2PixelStride = src2.getPixelStride();
213: int[] s2BandOffsets = src2.getBandOffsets();
214: byte[][] s2Data = src2.getByteDataArrays();
215:
216: int dwidth = dst.getWidth();
217: int dheight = dst.getHeight();
218: int bands = dst.getNumBands();
219: int dLineStride = dst.getScanlineStride();
220: int dPixelStride = dst.getPixelStride();
221: int[] dBandOffsets = dst.getBandOffsets();
222: byte[][] dData = dst.getByteDataArrays();
223:
224: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
225: byte[] s1 = s1Data[s1b];
226: byte[] s2 = s2Data[s2b];
227: byte[] d = dData[b];
228:
229: int s1LineOffset = s1BandOffsets[s1b];
230: int s2LineOffset = s2BandOffsets[s2b];
231: int dLineOffset = dBandOffsets[b];
232:
233: for (int h = 0; h < dheight; h++) {
234: int s1PixelOffset = s1LineOffset;
235: int s2PixelOffset = s2LineOffset;
236: int dPixelOffset = dLineOffset;
237:
238: s1LineOffset += s1LineStride;
239: s2LineOffset += s2LineStride;
240: dLineOffset += dLineStride;
241:
242: int diff = 0;
243: for (int w = 0; w < dwidth; w++) {
244: //
245: // The next two lines are a fast way to do
246: // a subtract with saturation on U8 elements.
247: // It eliminates the need to do clamping.
248: //
249: diff = (s1[s1PixelOffset] & 0xFF)
250: - (s2[s2PixelOffset] & 0xFF);
251: d[dPixelOffset] = (byte) ((diff & ~(diff >> 8)) & 0xFF);
252:
253: s1PixelOffset += s1PixelStride;
254: s2PixelOffset += s2PixelStride;
255: dPixelOffset += dPixelStride;
256: }
257: }
258: }
259: }
260:
261: private void computeRectUShort(RasterAccessor src1,
262: RasterAccessor src2, RasterAccessor dst) {
263: int s1LineStride = src1.getScanlineStride();
264: int s1PixelStride = src1.getPixelStride();
265: int[] s1BandOffsets = src1.getBandOffsets();
266: short[][] s1Data = src1.getShortDataArrays();
267:
268: int s2LineStride = src2.getScanlineStride();
269: int s2PixelStride = src2.getPixelStride();
270: int[] s2BandOffsets = src2.getBandOffsets();
271: short[][] s2Data = src2.getShortDataArrays();
272:
273: int dwidth = dst.getWidth();
274: int dheight = dst.getHeight();
275: int bands = dst.getNumBands();
276: int dLineStride = dst.getScanlineStride();
277: int dPixelStride = dst.getPixelStride();
278: int[] dBandOffsets = dst.getBandOffsets();
279: short[][] dData = dst.getShortDataArrays();
280:
281: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
282: short[] s1 = s1Data[s1b];
283: short[] s2 = s2Data[s2b];
284: short[] d = dData[b];
285:
286: int s1LineOffset = s1BandOffsets[s1b];
287: int s2LineOffset = s2BandOffsets[s2b];
288: int dLineOffset = dBandOffsets[b];
289:
290: for (int h = 0; h < dheight; h++) {
291: int s1PixelOffset = s1LineOffset;
292: int s2PixelOffset = s2LineOffset;
293: int dPixelOffset = dLineOffset;
294:
295: s1LineOffset += s1LineStride;
296: s2LineOffset += s2LineStride;
297: dLineOffset += dLineStride;
298:
299: for (int w = 0; w < dwidth; w++) {
300: d[dPixelOffset] = ImageUtil
301: .clampUShortNegative((int) (s1[s1PixelOffset] & 0xFFFF)
302: - (int) (s2[s2PixelOffset] & 0xFFFF));
303:
304: s1PixelOffset += s1PixelStride;
305: s2PixelOffset += s2PixelStride;
306: dPixelOffset += dPixelStride;
307: }
308: }
309: }
310: }
311:
312: private void computeRectShort(RasterAccessor src1,
313: RasterAccessor src2, RasterAccessor dst) {
314: int s1LineStride = src1.getScanlineStride();
315: int s1PixelStride = src1.getPixelStride();
316: int[] s1BandOffsets = src1.getBandOffsets();
317: short[][] s1Data = src1.getShortDataArrays();
318:
319: int s2LineStride = src2.getScanlineStride();
320: int s2PixelStride = src2.getPixelStride();
321: int[] s2BandOffsets = src2.getBandOffsets();
322: short[][] s2Data = src2.getShortDataArrays();
323:
324: int dwidth = dst.getWidth();
325: int dheight = dst.getHeight();
326: int bands = dst.getNumBands();
327: int dLineStride = dst.getScanlineStride();
328: int dPixelStride = dst.getPixelStride();
329: int[] dBandOffsets = dst.getBandOffsets();
330: short[][] dData = dst.getShortDataArrays();
331:
332: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
333: short[] s1 = s1Data[s1b];
334: short[] s2 = s2Data[s2b];
335: short[] d = dData[b];
336:
337: int s1LineOffset = s1BandOffsets[s1b];
338: int s2LineOffset = s2BandOffsets[s2b];
339: int dLineOffset = dBandOffsets[b];
340:
341: for (int h = 0; h < dheight; h++) {
342: int s1PixelOffset = s1LineOffset;
343: int s2PixelOffset = s2LineOffset;
344: int dPixelOffset = dLineOffset;
345:
346: s1LineOffset += s1LineStride;
347: s2LineOffset += s2LineStride;
348: dLineOffset += dLineStride;
349:
350: for (int w = 0; w < dwidth; w++) {
351: d[dPixelOffset] = ImageUtil
352: .clampShort((int) s1[s1PixelOffset]
353: - (int) s2[s2PixelOffset]);
354:
355: s1PixelOffset += s1PixelStride;
356: s2PixelOffset += s2PixelStride;
357: dPixelOffset += dPixelStride;
358: }
359: }
360: }
361: }
362:
363: private void computeRectInt(RasterAccessor src1,
364: RasterAccessor src2, RasterAccessor dst) {
365: int s1LineStride = src1.getScanlineStride();
366: int s1PixelStride = src1.getPixelStride();
367: int[] s1BandOffsets = src1.getBandOffsets();
368: int[][] s1Data = src1.getIntDataArrays();
369:
370: int s2LineStride = src2.getScanlineStride();
371: int s2PixelStride = src2.getPixelStride();
372: int[] s2BandOffsets = src2.getBandOffsets();
373: int[][] s2Data = src2.getIntDataArrays();
374:
375: int dwidth = dst.getWidth();
376: int dheight = dst.getHeight();
377: int bands = dst.getNumBands();
378: int dLineStride = dst.getScanlineStride();
379: int dPixelStride = dst.getPixelStride();
380: int[] dBandOffsets = dst.getBandOffsets();
381: int[][] dData = dst.getIntDataArrays();
382:
383: /*
384: * The destination data type may be any of the integral data types.
385: * The "clamp" function must clamp to the appropriate range for
386: * that data type.
387: */
388: switch (sampleModel.getTransferType()) {
389: case DataBuffer.TYPE_BYTE:
390: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
391: int[] s1 = s1Data[s1b];
392: int[] s2 = s2Data[s2b];
393: int[] d = dData[b];
394:
395: int s1LineOffset = s1BandOffsets[s1b];
396: int s2LineOffset = s2BandOffsets[s2b];
397: int dLineOffset = dBandOffsets[b];
398:
399: for (int h = 0; h < dheight; h++) {
400: int s1PixelOffset = s1LineOffset;
401: int s2PixelOffset = s2LineOffset;
402: int dPixelOffset = dLineOffset;
403:
404: s1LineOffset += s1LineStride;
405: s2LineOffset += s2LineStride;
406: dLineOffset += dLineStride;
407:
408: int diff = 0;
409: for (int w = 0; w < dwidth; w++) {
410: //
411: // The next two lines are a fast way to do
412: // a subtract with saturation on U8 elements.
413: // It eliminates the need to do clamping.
414: //
415: diff = (s1[s1PixelOffset] & 0xFF)
416: - (s2[s2PixelOffset] & 0xFF);
417: d[dPixelOffset] = ((diff & ~(diff >> 8)) & 0xFF);
418:
419: s1PixelOffset += s1PixelStride;
420: s2PixelOffset += s2PixelStride;
421: dPixelOffset += dPixelStride;
422: }
423: }
424: }
425: break;
426:
427: case DataBuffer.TYPE_USHORT:
428: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
429: int[] s1 = s1Data[s1b];
430: int[] s2 = s2Data[s2b];
431: int[] d = dData[b];
432:
433: int s1LineOffset = s1BandOffsets[s1b];
434: int s2LineOffset = s2BandOffsets[s2b];
435: int dLineOffset = dBandOffsets[b];
436:
437: for (int h = 0; h < dheight; h++) {
438: int s1PixelOffset = s1LineOffset;
439: int s2PixelOffset = s2LineOffset;
440: int dPixelOffset = dLineOffset;
441:
442: s1LineOffset += s1LineStride;
443: s2LineOffset += s2LineStride;
444: dLineOffset += dLineStride;
445:
446: for (int w = 0; w < dwidth; w++) {
447: d[dPixelOffset] = ImageUtil
448: .clampUShortNegative((s1[s1PixelOffset] & 0xFFFF)
449: - (s2[s2PixelOffset] & 0xFFFF));
450:
451: s1PixelOffset += s1PixelStride;
452: s2PixelOffset += s2PixelStride;
453: dPixelOffset += dPixelStride;
454: }
455: }
456: }
457: break;
458:
459: case DataBuffer.TYPE_SHORT:
460: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
461: int[] s1 = s1Data[s1b];
462: int[] s2 = s2Data[s2b];
463: int[] d = dData[b];
464:
465: int s1LineOffset = s1BandOffsets[s1b];
466: int s2LineOffset = s2BandOffsets[s2b];
467: int dLineOffset = dBandOffsets[b];
468:
469: for (int h = 0; h < dheight; h++) {
470: int s1PixelOffset = s1LineOffset;
471: int s2PixelOffset = s2LineOffset;
472: int dPixelOffset = dLineOffset;
473:
474: s1LineOffset += s1LineStride;
475: s2LineOffset += s2LineStride;
476: dLineOffset += dLineStride;
477:
478: for (int w = 0; w < dwidth; w++) {
479: d[dPixelOffset] = ImageUtil
480: .clampShort(s1[s1PixelOffset]
481: - s2[s2PixelOffset]);
482:
483: s1PixelOffset += s1PixelStride;
484: s2PixelOffset += s2PixelStride;
485: dPixelOffset += dPixelStride;
486: }
487: }
488: }
489: break;
490:
491: case DataBuffer.TYPE_INT:
492: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
493: int[] s1 = s1Data[s1b];
494: int[] s2 = s2Data[s2b];
495: int[] d = dData[b];
496:
497: int s1LineOffset = s1BandOffsets[s1b];
498: int s2LineOffset = s2BandOffsets[s2b];
499: int dLineOffset = dBandOffsets[b];
500:
501: for (int h = 0; h < dheight; h++) {
502: int s1PixelOffset = s1LineOffset;
503: int s2PixelOffset = s2LineOffset;
504: int dPixelOffset = dLineOffset;
505:
506: s1LineOffset += s1LineStride;
507: s2LineOffset += s2LineStride;
508: dLineOffset += dLineStride;
509:
510: for (int w = 0; w < dwidth; w++) {
511: d[dPixelOffset] = ImageUtil
512: .clampInt((long) s1[s1PixelOffset]
513: - (long) s2[s2PixelOffset]);
514:
515: s1PixelOffset += s1PixelStride;
516: s2PixelOffset += s2PixelStride;
517: dPixelOffset += dPixelStride;
518: }
519: }
520: }
521: break;
522: }
523: }
524:
525: private void computeRectFloat(RasterAccessor src1,
526: RasterAccessor src2, RasterAccessor dst) {
527: int s1LineStride = src1.getScanlineStride();
528: int s1PixelStride = src1.getPixelStride();
529: int[] s1BandOffsets = src1.getBandOffsets();
530: float[][] s1Data = src1.getFloatDataArrays();
531:
532: int s2LineStride = src2.getScanlineStride();
533: int s2PixelStride = src2.getPixelStride();
534: int[] s2BandOffsets = src2.getBandOffsets();
535: float[][] s2Data = src2.getFloatDataArrays();
536:
537: int dwidth = dst.getWidth();
538: int dheight = dst.getHeight();
539: int bands = dst.getNumBands();
540: int dLineStride = dst.getScanlineStride();
541: int dPixelStride = dst.getPixelStride();
542: int[] dBandOffsets = dst.getBandOffsets();
543: float[][] dData = dst.getFloatDataArrays();
544:
545: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
546: float[] s1 = s1Data[s1b];
547: float[] s2 = s2Data[s2b];
548: float[] d = dData[b];
549:
550: int s1LineOffset = s1BandOffsets[s1b];
551: int s2LineOffset = s2BandOffsets[s2b];
552: int dLineOffset = dBandOffsets[b];
553:
554: for (int h = 0; h < dheight; h++) {
555: int s1PixelOffset = s1LineOffset;
556: int s2PixelOffset = s2LineOffset;
557: int dPixelOffset = dLineOffset;
558:
559: s1LineOffset += s1LineStride;
560: s2LineOffset += s2LineStride;
561: dLineOffset += dLineStride;
562:
563: for (int w = 0; w < dwidth; w++) {
564: d[dPixelOffset] = s1[s1PixelOffset]
565: - s2[s2PixelOffset];
566:
567: s1PixelOffset += s1PixelStride;
568: s2PixelOffset += s2PixelStride;
569: dPixelOffset += dPixelStride;
570: }
571: }
572: }
573: }
574:
575: private void computeRectDouble(RasterAccessor src1,
576: RasterAccessor src2, RasterAccessor dst) {
577: int s1LineStride = src1.getScanlineStride();
578: int s1PixelStride = src1.getPixelStride();
579: int[] s1BandOffsets = src1.getBandOffsets();
580: double[][] s1Data = src1.getDoubleDataArrays();
581:
582: int s2LineStride = src2.getScanlineStride();
583: int s2PixelStride = src2.getPixelStride();
584: int[] s2BandOffsets = src2.getBandOffsets();
585: double[][] s2Data = src2.getDoubleDataArrays();
586:
587: int dwidth = dst.getWidth();
588: int dheight = dst.getHeight();
589: int bands = dst.getNumBands();
590: int dLineStride = dst.getScanlineStride();
591: int dPixelStride = dst.getPixelStride();
592: int[] dBandOffsets = dst.getBandOffsets();
593: double[][] dData = dst.getDoubleDataArrays();
594:
595: for (int b = 0, s1b = 0, s2b = 0; b < bands; b++, s1b += s1bd, s2b += s2bd) {
596: double[] s1 = s1Data[s1b];
597: double[] s2 = s2Data[s2b];
598: double[] d = dData[b];
599:
600: int s1LineOffset = s1BandOffsets[s1b];
601: int s2LineOffset = s2BandOffsets[s2b];
602: int dLineOffset = dBandOffsets[b];
603:
604: for (int h = 0; h < dheight; h++) {
605: int s1PixelOffset = s1LineOffset;
606: int s2PixelOffset = s2LineOffset;
607: int dPixelOffset = dLineOffset;
608:
609: s1LineOffset += s1LineStride;
610: s2LineOffset += s2LineStride;
611: dLineOffset += dLineStride;
612:
613: for (int w = 0; w < dwidth; w++) {
614: d[dPixelOffset] = s1[s1PixelOffset]
615: - s2[s2PixelOffset];
616:
617: s1PixelOffset += s1PixelStride;
618: s2PixelOffset += s2PixelStride;
619: dPixelOffset += dPixelStride;
620: }
621: }
622: }
623: }
624:
625: // public static void main(String args[]) {
626: // System.out.println("SubtractOpImage Test");
627: // ImageLayout layout;
628: // OpImage src1, src2, dst;
629: // Rectangle rect = new Rectangle(0, 0, 5, 5);
630:
631: // System.out.println("1. PixelInterleaved byte 3-band");
632: // layout = OpImageTester.createImageLayout(
633: // 0, 0, 800, 800, 0, 0, 200, 200, DataBuffer.TYPE_BYTE, 3, false);
634: // src1 = OpImageTester.createRandomOpImage(layout);
635: // src2 = OpImageTester.createRandomOpImage(layout);
636: // dst = new SubtractOpImage(src1, src2, null, null);
637: // OpImageTester.testOpImage(dst, rect);
638: // OpImageTester.timeOpImage(dst, 10);
639:
640: // System.out.println("2. Banded byte 3-band");
641: // layout = OpImageTester.createImageLayout(
642: // 0, 0, 800, 800, 0, 0, 200, 200, DataBuffer.TYPE_BYTE, 3, true);
643: // src1 = OpImageTester.createRandomOpImage(layout);
644: // src2 = OpImageTester.createRandomOpImage(layout);
645: // dst = new SubtractOpImage(src1, src2, null, null);
646: // OpImageTester.testOpImage(dst, rect);
647: // OpImageTester.timeOpImage(dst, 10);
648:
649: // System.out.println("3. PixelInterleaved int 3-band");
650: // layout = OpImageTester.createImageLayout(
651: // 0, 0, 512, 512, 0, 0, 200, 200, DataBuffer.TYPE_INT, 3, false);
652: // src1 = OpImageTester.createRandomOpImage(layout);
653: // src2 = OpImageTester.createRandomOpImage(layout);
654: // dst = new SubtractOpImage(src1, src2, null, null);
655: // OpImageTester.testOpImage(dst, rect);
656: // OpImageTester.timeOpImage(dst, 10);
657:
658: // System.out.println("4. Banded int 3-band");
659: // layout = OpImageTester.createImageLayout(
660: // 0, 0, 512, 512, 0, 0, 200, 200, DataBuffer.TYPE_INT, 3, true);
661: // src1 = OpImageTester.createRandomOpImage(layout);
662: // src2 = OpImageTester.createRandomOpImage(layout);
663: // dst = new SubtractOpImage(src1, src2, null, null);
664: // OpImageTester.testOpImage(dst, rect);
665: // OpImageTester.timeOpImage(dst, 10);
666: // }
667: }
|