本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: visualize
public PImage visualize() {
PImage out = new PImage(width, height, PConstants.RGB);
for( SimpleContour sc : contour ) {
sc.visualize(out,0xFFFF0000,0xFF00FF00);
}
return out;
}
示例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;
}
示例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;
}
示例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;
}