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