dstCM = src.getColorModel();
return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth()*2, src.getHeight()*2), dstCM.isAlphaPremultiplied(), null);
}
public BufferedImage pyramidExpand(BufferedImage src) {
int width = src.getWidth();
int height = src.getHeight();
int[] inPixels = new int[width*height];
getRGB(src, 0, 0, width, height, inPixels );
int ow = 2*width;
int oh =2*height;
int[] outPixels = new int[ow * oh];
int index = 0, outdex = 0, ta = 0;
float[][] keneralData = this.getHVGaussianKeneral();
BufferedImage dest = createTwiceCompatibleDestImage(src, null);
for(int row=0; row
for(int subRow = -2; subRow <= 2; subRow++) {
double srcRow = (row + subRow)/2.0;
double j = Math.floor(srcRow);
double t = srcRow - j;
if(t > 0) {
continue;
}
if(srcRow >= height || srcRow < 0) {
srcRow = 0;
}
for(int subCol = -2; subCol <= 2; subCol++) {
double srcColOff = (col + subCol)/2.0;
j = Math.floor(srcColOff);
t = srcColOff - j;
if(t > 0) {
continue;
}
if(srcColOff >= width || srcColOff < 0) {
srcColOff = 0;
}
index = (int)(srcRow * width + srcColOff);
ta = (inPixels[index] >> 24) & 0xff;
int red = (inPixels[index] >> 16) & 0xff;
int green = (inPixels[index] >> 8) & 0xff;
int blue = inPixels[index] & 0xff;
sumRed += keneralData[subRow + 2][subCol + 2] * red;
sumGreen += keneralData[subRow + 2][subCol + 2] * green;
sumBlue += keneralData[subRow + 2][subCol + 2] * blue;
}
}
outdex = row * ow + col;
outPixels[outdex] = (ta << 24) | (clamp(4.0f * sumRed) << 16) | (clamp(4.0f * sumGreen) << 8) | clamp(4.0f * sumBlue);
// outPixels[outdex] = (ta << 24) | (clamp(sumRed) << 16) | (clamp(sumGreen) << 8) | clamp(sumBlue);
}
}
setRGB( dest, 0, 0, ow, oh, outPixels );
return dest;
}
}
package com.gloomyfish.image.pyramid;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
public class PyramidAlgorithm extends GaussianFilter {
private float a;
public PyramidAlgorithm() {
a = 0.4f;
}
public void setParameter(float p) {
this.a = p;
}
public BufferedImage[] pyramidDown(BufferedImage src, int level) {
BufferedImage[] imagePyramids = new BufferedImage[level + 1];
imagePyramids[0] = src;
for(int i=1; i
}
return imagePyramids;
}
public BufferedImage[] pyramidUp(BufferedImage[] srcImage) {
BufferedImage[] imagePyramids = new BufferedImage[srcImage.length];
for(int i=0; i
}
return imagePyramids;
}
/***
* l1 = g1 - expand(g2)
* l2 = g2 - expand(g3)
* l0 = g0 - expand(g1)
* @param redu