Javaのユーザ定義関数に従ってイメージをワープします。一般に、画像は比較的大きい(JPEG、30〜50MB)。自分の関数に従ったJavaの高速画像ワーピング
はまず、イメージがロードされている:
BufferedImage img = ImageIO.read("image.jpg");
と仮定[X、Y] [X、Y]は、そのピクセル座標を表す画像のリサンプリングピクセル座標であること。
座標の関数である(簡単な例)次のように書かれた:
X = y * cos(x);
Y = x;
私のアイデアは、ピクセルごとの変換を使用することである。
//Get size of the raster
int width = img.getWidth(), height = img.getHeight();
int proj_width = (int)(width * Math.cos(height*Math.pi/180)),proj_height = height;
//Create output image
BufferedImage img2 = new BufferedImage(proj_width+1, proj_height+1, img.getType());
//Reproject raster
for (int i = 0; i < img.getWidth(); i++) {
for (int j = 0; j < img.getHeight(); j++) {
//Color of the pixel
int col = img.getRGB(i, j);
//Its new coordinates
int X = (int)(i * Math.cos(j*Math.pi/180));
int Y = j;
//Set X,Y,col to the new raster
img2.setRGB(X,Y,col);
}
}
を実現するための任意のより高速な方法はあります追加のライブラリを使用せずにこの操作を行いますか?ワープクラスのwarpRect()メソッドを使用して、例えば
...あなたの助けを
感謝。
「ワープ」クラスとは何ですか?これはすでに別の図書館のようです... – haraldK