在此代碼中,我將圖像作爲輸入並輸出相同的圖像。據我所知,如果兩幅圖像相同,那麼它們的PSNR值將是inf。所以我使用MATLAB來計算他們的PSNR值,但它顯示了48.05,這意味着這些圖像不一樣。但我讀和寫相同的圖像,爲什麼發生這種情況。我該如何解決它?Java中的圖像輸入輸出
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();
}
}
讓我知道如果它爲png格式 –
由於同樣的,它的PNG格式 –
涼爽的工作,你介意打綠色的勾號? –