[英]image processing
我想更改圖像中像素的值,我需要將圖像存儲為矩陣。 我怎么能完成這份工作? 請指導。
BufferedImage image = ImageIO.read(..);
image.setRGB(x, y, rgb);
查看BufferedImage
的文檔
使用image.setRGB非常慢。
您可以使用Catalano Framework
例:
FastBitmap fb = new FastBitmap(bufferedImage);
int x = fb.getRed(0,0);
//If you prefer to retrieve the matrix you can do too.
int[][][] image = new int[fb.getHeight][fb.getWidth][3];
fb.toArrayRGB(image);
首先將圖像讀入BufferedImage。
BufferedImage image = ImageIO.read(new File("..."));
然后像這樣在2D數組中創建矩陣狀結構並設置RGB:
for(int i = 0; i < image.getWidth(); i++){
for(int j = 0; j < image.getHeight(); j++){
image.setRGB(i, j, rgb);
}
}
圖像是數據的2d表示(像素信息)
2D表示x和y方向。 在圖像的情況下,這些方向通常被視為行和列
要更改像素值,我們必須在這些行和列中獲取其位置
獲得像素位置就像那位班級老師用他的坐姿來解決這位未知學生(例如:第2工作室第3人)
像這樣,我們必須通過行和列位置來處理像素
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.