當前位置: 首頁>>代碼示例>>Java>>正文


Java PConstants.RGB屬性代碼示例

本文整理匯總了Java中processing.core.PConstants.RGB屬性的典型用法代碼示例。如果您正苦於以下問題:Java PConstants.RGB屬性的具體用法?Java PConstants.RGB怎麽用?Java PConstants.RGB使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在processing.core.PConstants的用法示例。


在下文中一共展示了PConstants.RGB屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createImageFrom

public static opencv_core.IplImage createImageFrom(PImage in) {
        // TODO: avoid this creation !!
        opencv_core.CvSize outSize = new opencv_core.CvSize();
        outSize.width(in.width);
        outSize.height(in.height);
//        System.out.println("inputImage to create an IPL:" + in.width + " " + in.height + " " + in.format);
        opencv_core.IplImage imgOut = null;
        if (in.format == PConstants.RGB) {
            imgOut = cvCreateImage(outSize, opencv_core.IPL_DEPTH_8U, // depth
            3);
        }
        if (in.format == PConstants.ALPHA || in.format == PConstants.GRAY) {
            imgOut = cvCreateImage(outSize, opencv_core.IPL_DEPTH_8U, // depth
            1);
        }
        if (in.format == PConstants.ARGB) {
            imgOut = cvCreateImage(outSize, opencv_core.IPL_DEPTH_8U, // depth
            4);
        }
        //        imgIn.w
        return imgOut;
    }
 
開發者ID:poqudrof,項目名稱:PapARt,代碼行數:22,代碼來源:ImageUtils.java

示例2: colorizeSign

/**
 * Renders positive values as red and negative values as green.  The intensity of the color is a linear
 * function relative to the maximum intensity of the image.
 *
 * @param src Input image.
 * @param maxAbsValue The maximum absolute value of the image.
 * @return Visualized image.
 */
public static PImage colorizeSign(GrayF32 src, float maxAbsValue) {
	PImage out = new PImage(src.width, src.height, PConstants.RGB);

	int indexOut = 0;
	for (int y = 0; y < src.height; y++) {
		for (int x = 0; x < src.width; x++, indexOut++ ) {
			float v = src.get(x, y);

			int rgb;
			if (v > 0) {
				rgb = (int) (255 * v / maxAbsValue) << 16;
			} else {
				rgb = (int) (-255 * v / maxAbsValue) << 8;
			}
			out.pixels[indexOut] = rgb;
		}
	}

	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:28,代碼來源:VisualizeProcessing.java

示例3: convert

public PImage convert() {
	PImage out = new PImage(image.width,image.height, PConstants.RGB);
	if( image.getBandType() == GrayF32.class) {
		ConvertProcessing.convert_PF32_RGB(image, out);
	} else if( image.getBandType() == GrayU8.class ) {
		ConvertProcessing.convert_PU8_RGB(image,out);
	} else {
		throw new RuntimeException("Unknown image type");
	}
	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:11,代碼來源:SimpleColor.java

示例4: labeled

/**
 * Renders a labeled image with the provided lookup table for each region's RGB color.
 *
 * @param image Input labeled image
 * @param colors Color lookup table
 * @return Visualized image
 */
public static PImage labeled(GrayS32 image, int[] colors) {
	PImage out = new PImage(image.width, image.height, PConstants.RGB);

	int indexOut = 0;
	for (int y = 0; y < image.height; y++) {
		int indexImage = image.startIndex + image.stride*y;
		for (int x = 0; x < image.width; x++,indexImage++,indexOut++) {
			out.pixels[indexOut] = colors[image.data[indexImage]];
		}
	}

	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:20,代碼來源:VisualizeProcessing.java

示例5: visualize

public PImage visualize() {
	PImage out = new PImage(width, height, PConstants.RGB);

	for( SimpleContour sc : contour ) {
		sc.visualize(out,0xFFFF0000,0xFF00FF00);
	}

	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:9,代碼來源:SimpleContourList.java

示例6: visualize

public PImage visualize() {
	PImage out = new PImage(image.width, image.height, PConstants.RGB);

	int indexOut = 0;
	for (int y = 0; y < image.height; y++) {
		int indexIn = image.startIndex + image.stride*y;
		for (int x = 0; x < image.width; x++,indexIn++,indexOut++) {
			out.pixels[indexOut] = image.data[indexIn] == 0 ? 0xFF000000 : 0xFFFFFFFF;
		}
	}

	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:13,代碼來源:SimpleBinary.java

示例7: convert

public PImage convert() {
	PImage out = new PImage(image.width,image.height, PConstants.RGB);
	if( image instanceof GrayF32) {
		ConvertProcessing.convert_F32_RGB((GrayF32)image,out);
	} else if( image instanceof GrayU8 ) {
		ConvertProcessing.convert_U8_RGB((GrayU8) image, out);
	} else {
		throw new RuntimeException("Unknown image type");
	}
	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:11,代碼來源:SimpleGray.java

示例8: gradient

/**
 * Renders the image gradient into a single output image.  Each direction has a unique color and the
 * intensity is dependent upon the edge's relative intensity
 * @param dx Derivative x-axis
 * @param dy Derivative y-axis
 * @return Visualized image
 */
public static PImage gradient(GrayF32 dx, GrayF32 dy) {
	PImage out = new PImage(dx.width, dx.height, PConstants.RGB);

	float maxAbsValue = ImageStatistics.maxAbs(dx);
	maxAbsValue = Math.max(maxAbsValue, ImageStatistics.maxAbs(dy));
	if( maxAbsValue == 0 )
		return out;

	int indexOut = 0;
	for (int y = 0; y < dx.height; y++) {
		int indexX = dx.startIndex + dx.stride*y;
		int indexY = dy.startIndex + dy.stride*y;

		for (int x = 0; x < dy.width; x++,indexX++,indexY++,indexOut++) {

			float valueX = dx.data[ indexX ];
			float valueY = dy.data[ indexY ];

			int r=0,g=0,b=0;

			if( valueX > 0 ) {
				r = (int)(255*valueX/maxAbsValue);
			} else {
				g = (int)(-255*valueX/maxAbsValue);
			}
			if( valueY > 0 ) {
				b = (int)(255*valueY/maxAbsValue);
			} else {
				int v = (int)(-255*valueY/maxAbsValue);
				r += v;
				g += v;
				if( r > 255 ) r = 255;
				if( g > 255 ) g = 255;
			}

			out.pixels[indexOut] = 0xFF << 24 | r << 16 | g << 8 | b;
		}
	}

	return out;
}
 
開發者ID:lessthanoptimal,項目名稱:BoofProcessing,代碼行數:48,代碼來源:VisualizeProcessing.java


注:本文中的processing.core.PConstants.RGB屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。