在这段代码中,我将一幅图像作为输入并输出相同的图像。据我所知,如果两个图像相同,则它们的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();
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句