[英]Image input output in Java
在這段代碼中,我將一幅圖像作為輸入並輸出相同的圖像。 據我所知,如果兩個圖像相同,則它們的PSNR值將為inf。 因此,我使用MATLAB計算了它們的PSNR值,但顯示48.05意味着這些圖像不相同。 但是我讀寫相同的圖像,為什么會這樣。 我該如何解決?
public class ImageProcessing {
BufferedImage image = null;
int width;
int height;
public ImageProcessing() {
// Input the image
try {
File input = new File("image0.jpg");
image = ImageIO.read(input);
width = image.getWidth();
height = image.getHeight();
/*int count = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
count++;
Color c = new Color(image.getRGB(j, i));
System.out.println("S.No: " + count + " Red: " + c.getRed() + " Green: " + c.getGreen() + " Blue: " + c.getBlue());
}
}*/
} catch (Exception e) {
System.out.println("Error: " + e);
}
// Output the image
try {
File input = new File("image1.jpg");
ImageIO.write(image, "jpg", input);
System.out.println("Writing complete.");
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
public static void main(String[] args) {
// TODO code application logic here
System.out.println("System Start");
ImageProcessing obj = new ImageProcessing();
}
}
是的,為了擺脫Salmans的評論,采用無損壓縮,原來文件中的每一位數據在未壓縮后都會保留下來。 通常用於可能丟失信息(例如財務數據)的txt文檔或電子表格文件。 PNG或GIF使用無損壓縮。 使用損耗壓縮的優點是什么? 通過刪除冗余信息,文件變得更小。 通常,用戶不會注意到它,而是用於聲音和視頻。 JPEG使用有損壓縮,通常創建者可以決定在文件大小和圖像質量之間進行折衷以引入多少損失。
主要來自以下網站 : http : //whatis.techtarget.com/definition/lossless-and-lossy-compression
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.