本文整理汇总了Java中com.jhlabs.image.ImageMath类的典型用法代码示例。如果您正苦于以下问题:Java ImageMath类的具体用法?Java ImageMath怎么用?Java ImageMath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageMath类属于com.jhlabs.image包,在下文中一共展示了ImageMath类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
public float evaluate(float x, float y) {
int ix = (int)x;
int iy = (int)y;
if (edgeAction == WRAP) {
ix = ImageMath.mod(ix, width);
iy = ImageMath.mod(iy, height);
} else if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
if (edgeAction == ZERO)
return 0;
if (ix < 0)
ix = 0;
else if (ix >= width)
ix = width-1;
if (iy < 0)
iy = 0;
else if (iy >= height)
iy = height-1;
}
return alpha ? ((pixels[iy*width+ix] >> 24) & 0xff) / 255.0f : PixelUtils.brightness(pixels[iy*width+ix]) / 255.0f;
}
示例2: transformInverse
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
float dx = x - cx;
float dy = cy - y;
double r = Math.sqrt(dx * dx + dy * dy);
double radius = srcHeight * zoom / 2;
double angle = Utils.transformAtan2AngleToIntuitive(FastMath.atan2(dy, dx)) + rotateResult;
if (angle > (2 * Math.PI)) {
angle -= 2 * Math.PI;
}
float nx = (float) ((angle * srcWidth) / (2 * Math.PI));
float ratio = (float) (r / radius);
float correctedRatio = ImageMath.bias(ratio, innerZoom);
float ny = correctedRatio * srcHeight;
if(!inverted) {
ny = srcHeight - ny;
}
out[0] = nx;
out[1] = ny;
}
示例3: evaluate
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
public float evaluate(float x, float y) {
int ix = (int)x;
int iy = (int)y;
if (edgeAction == WRAP) {
ix = ImageMath.mod(ix, width);
iy = ImageMath.mod(iy, height);
} else if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
if (edgeAction == ZERO) {
return 0;
}
if (ix < 0) {
ix = 0;
} else if (ix >= width) {
ix = width-1;
}
if (iy < 0) {
iy = 0;
} else if (iy >= height) {
iy = height-1;
}
}
return alpha ? ((pixels[iy*width+ix] >> 24) & 0xff) / 255.0f : PixelUtils.brightness(pixels[iy*width+ix]) / 255.0f;
}
示例4: interpolateColor
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
public static Color interpolateColor(Color startColor, Color endColor, float progress) {
int initialRGB = startColor.getRGB();
int finalRGB = endColor.getRGB();
// linear interpolation in the RGB space
// possibly interpolating in HSB space would be better
int interpolatedRGB = ImageMath.mixColors(progress, initialRGB, finalRGB);
return new Color(interpolatedRGB);
}
示例5: perlinNoise2D
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
/**
* A 2D version of the algorithm from http://mrl.nyu.edu/~perlin/noise/
*/
private static float perlinNoise2D(float x, float y) {
// find unit grid cell containing point + wrap the integer cells at 255
int gridX = ((int) x) & 255;
int gridY = ((int) y) & 255;
// get relative coordinates of point within cell
x -= ((int) x);
y -= ((int) y);
// compute the fade curves for x and y
float u = fade(x);
float v = fade(y);
// calculate hashed gradient indices
int a = p[gridX] + gridY;
int aa = p[a];
int ab = p[a + 1];
int b = p[gridX + 1] + gridY;
int ba = p[b];
int bb = p[b + 1];
float noiseSE = grad2D(p[aa], x, y);
float noiseSW = grad2D(p[ba], x - 1, y);
float noiseNE = grad2D(p[ab], x, y - 1);
float noiseNW = grad2D(p[bb], x - 1, y - 1);
float noiseS = ImageMath.lerp(u, noiseSE, noiseSW);
float noiseN = ImageMath.lerp(u, noiseNE, noiseNW);
float noise = ImageMath.lerp(v, noiseS, noiseN);
// noise is in the range [-1..1]
return noise;
}
示例6: transformInverse
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
float dx = x - cx;
float dy = y - cy;
double r = Math.sqrt(dx * dx + dy * dy);
double angle = FastMath.atan2(dy, dx);
double na = r / radialWL - phase;
double fa;
switch (waveType) {
case WaveType.SINE:
fa = FastMath.sin(na);
break;
case WaveType.SAWTOOTH:
fa = ImageMath.sinLikeSawtooth(na);
break;
case WaveType.TRIANGLE:
fa = ImageMath.sinLikeTriangle(na);
break;
case WaveType.NOISE:
fa = Noise.sinLikeNoise1((float)na);
break;
default:
throw new IllegalStateException("waveType = " + waveType);
}
angle += fa * amount;
double zoomedR = r / zoom;
float u = (float) (zoomedR * FastMath.cos(angle));
float v = (float) (zoomedR * FastMath.sin(angle));
out[0] = (u + cx);
out[1] = (v + cy);
}
示例7: transformInverse
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
float dx = x - cx;
float dy = y - cy;
double r = Math.sqrt(dx * dx + dy * dy);
double angle = FastMath.atan2(dy, dx);
// double angularWL = 1.0 / angularDivision;
double nr = angle * angularDivision - phase;
double fr;
switch (waveType) {
case WaveType.SINE:
fr = FastMath.sin(nr);
break;
case WaveType.SAWTOOTH:
fr = ImageMath.sinLikeSawtooth(nr);
break;
case WaveType.TRIANGLE:
fr = ImageMath.sinLikeTriangle(nr);
break;
case WaveType.NOISE:
fr = Noise.sinLikeNoise1((float)nr);
break;
default:
throw new IllegalStateException("waveType = " + waveType);
}
r += fr * radialAmplitude * r / maxSize;
double zoomedR = r / zoom;
float u = (float) (zoomedR * FastMath.cos(angle));
float v = (float) (zoomedR * FastMath.sin(angle));
out[0] = (u + cx);
out[1] = (v + cy);
}
示例8: getInterpolatedPositions
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
private float[] getInterpolatedPositions(float progress, GState grEndState) {
float[] interpolatedPositions = new float[thumbPositions.length];
for (int i = 0; i < thumbPositions.length; i++) {
float initial = thumbPositions[i];
float end = grEndState.thumbPositions[i];
float interpolated = ImageMath.lerp(progress, initial, end);
interpolatedPositions[i] = interpolated;
}
return interpolatedPositions;
}
示例9: interpolate
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
public ParamState interpolate(ParamState endState, double progress) {
IPPState ippEndState = (IPPState) endState;
double interpolatedX = ImageMath.lerp(progress, relativeX, ippEndState.relativeX);
double interpolatedY = ImageMath.lerp(progress, relativeY, ippEndState.relativeY);
return new IPPState(interpolatedX, interpolatedY);
}
示例10: interpolate
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
public ParamState interpolate(ParamState endState, double progress) {
GRState apEndState = (GRState) endState;
double[] interpolatedValues = new double[values.length];
for (int i = 0; i < values.length; i++) {
interpolatedValues[i] = ImageMath.lerp(progress, values[i], apEndState.values[i]);
}
return new GRState(interpolatedValues);
}
示例11: sinLikeNoise1
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
/**
* A noise function with a "period" of 2 PI and values between -1 and 1
*/
public static float sinLikeNoise1(float x) {
return 2 * Noise.noise1(x / ImageMath.PI);
}
示例12: doTransform
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
ReseedSupport.reInitialize();
Random rand = ReseedSupport.getRand();
int[] srcData = ImageUtils.getPixelsAsArray(src);
int[] destData = ImageUtils.getPixelsAsArray(dest);
float opacityValueAsPercentage = opacity.getValueAsPercentage();
int opacityValue = opacity.getValue();
float saturationValueAsPercentage = saturation.getValueAsPercentage();
int saturationValue = saturation.getValue();
float coverageValue = coverage.getValueAsPercentage();
boolean coverageAnim = method.getValue() == METHOD_COVERAGE_ANIM;
for (int i = 0; i < destData.length; i++) {
int srcRGB = srcData[i];
int randomInt = 0;
if (coverageAnim) {
// generate random numbers for the discarded pixels as well
randomInt = rand.nextInt();
}
float rn = rand.nextFloat();
if (rn > coverageValue) {
destData[i] = srcRGB;
continue;
}
int sourceAlpha = 0xFF000000 & srcRGB;
if (sourceAlpha == 0) { // for premultiplied
destData[i] = 0;
continue;
}
if (!coverageAnim) {
// if coverage animation is not a requirement, then it is faster
// to generate the random values only here, for the covered pixels
randomInt = rand.nextInt();
}
if(saturationValue == 100) {
// make the alpha channel the same as for the source
randomInt |= sourceAlpha;
if (opacityValue == 100) {
destData[i] = randomInt;
} else {
destData[i] = ImageMath.mixColors(opacityValueAsPercentage, srcRGB, randomInt);
}
} else {
int r = (randomInt >>> 16) & 0xFF;
int g = (randomInt >>> 8) & 0xFF;
int b = (randomInt) & 0xFF;
Color.RGBtoHSB(r, g, b, tmpHSV);
float newSaturation = ImageMath.lerp(saturationValueAsPercentage, 0.0f, tmpHSV[1]);
randomInt = Color.HSBtoRGB(tmpHSV[0], newSaturation, tmpHSV[2]);
// make the alpha channel the same as for the source
randomInt |= sourceAlpha;
if (opacityValue == 100) {
destData[i] = randomInt;
} else {
destData[i] = ImageMath.mixColors(opacityValueAsPercentage, srcRGB, randomInt);
}
}
}
return dest;
}
示例13: interpolate
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
public ParamState interpolate(ParamState endState, double progress) {
APState apEndState = (APState) endState;
double interpolatedAngle = ImageMath.lerp(progress, angle, apEndState.angle);
return new APState(interpolatedAngle);
}
示例14: interpolate
import com.jhlabs.image.ImageMath; //导入依赖的package包/类
@Override
public RPState interpolate(ParamState endState, double progress) {
RPState rpEndState = (RPState) endState;
double interpolated = ImageMath.lerp(progress, value, rpEndState.value);
return new RPState(interpolated);
}