日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > java >内容正文

java

离散图 java,Java实现离散Arnold变换(图像处理)

發(fā)布時間:2024/9/19 java 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 离散图 java,Java实现离散Arnold变换(图像处理) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原始124×124pix

原圖1次2次3次

15次

周期表:

N

2

3

4

5

6

7

8

9

10

11

12

周期

3

4

3

10

12

8

6

12

30

5

12

N

13

14

15

16

17

18

19

20

21

22

23

周期

14

24

20

12

18

12

9

30

8

15

24

N

25

50

60

100

120

125

128

256

480

512

1024

周期

50

150

60

150

60

250

96

192

120

384

768

package com.zeph.j2se.arnold;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import javax.imageio.ImageIO;

/**

* Arnold's Cat Map(Arnold變換)

*

* @author BenZeph

*

*/

public class Arnold {

private File srcImageFile, desImageFile;

private BufferedImage srcImage, desImage;

private int[][] srcMatrix, desMatrix;

private int N;// 圖像的長度(寬度)

private int time;// 周期

/**

* Arnold's Cat Map(Arnold變換)

*

* @param srcImageFile

* @param desImageFile

* @param time

* 周期

*/

public Arnold(File srcImageFile, File desImageFile, int time) {

this.srcImageFile = srcImageFile;

this.desImageFile = desImageFile;

this.time = time;

}

/**

* 讀取圖像

*

* @param imageFile

* @return

*/

public BufferedImage readImage(File imageFile) {

BufferedImage image = null;

try {

image = ImageIO.read(imageFile);

} catch (IOException e) {

e.printStackTrace();

}

return image;

}

/**

* 獲取圖像RGB矩陣

*

* @param image

* @return

*/

public int[][] getMatrixRGB(BufferedImage image) {

int width = image.getWidth();

int height = image.getHeight();

int[][] imageMatrix = new int[height][width];

for (int i = 0; i < height; i++) {

for (int j = 0; j < width; j++) {

imageMatrix[i][j] = image.getRGB(i, j);

}

}

return imageMatrix;

}

/**

* 寫入圖像

*

* @param filePath

*/

public void writeImage(File imageFile, BufferedImage image) {

try {

ImageIO.write(image, "jpg", imageFile);

} catch (IOException e) {

e.printStackTrace();

}

}

/**

* Arnold變換初始化

*

* @param image

* @return

*/

public boolean initArnold(BufferedImage image) {

int width = image.getWidth();

int height = image.getHeight();

if (width != height) {

return false;

} else {

N = width;

srcMatrix = getMatrixRGB(image);

desMatrix = new int[N][N];

desImage = new BufferedImage(width, height, srcImage.getType());

return true;

}

}

/**

* Arnold變換

*/

public void arnoldTransform() {

srcImage = readImage(srcImageFile);

if (initArnold(srcImage)) {

for (int n = 0; n < time; n++) {

if (n != 0) {

srcMatrix = desMatrix;

desMatrix = new int[N][N];

}

for (int i = 0; i < N; i++) {

for (int j = 0; j < N; j++) {

desMatrix[(i + j) % N][(i + 2 * j) % N] = srcMatrix[i][j];

}

}

}

for (int i = 0; i < N; i++) {

for (int j = 0; j < N; j++) {

desImage.setRGB(i, j, desMatrix[i][j]);

}

}

}

writeImage(desImageFile, desImage);

}

public static void main(String[] args) {

File srcImageFile = new File("D://lena124.jpg");

File desImageFile = new File("D://15.jpg");

Arnold arnold = new Arnold(srcImageFile, desImageFile, 15);

arnold.arnoldTransform();

}

}

總結(jié)

以上是生活随笔為你收集整理的离散图 java,Java实现离散Arnold变换(图像处理)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。