如何使用基于均方误差的基于像素的图像比较度量来比较java中的图像集?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何使用基于均方误差的基于像素的图像比较度量来比较java中的图像集?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2588字,纯文字阅读大概需要4分钟。
内容图文
![如何使用基于均方误差的基于像素的图像比较度量来比较java中的图像集?](/upload/InfoBanner/zyjiaocheng/708/8ea06b3716e84b808148a502b6d210ff.jpg)
在我的项目中,我有一组图像.我需要比较它们.将来自一个图像的每个像素与数据集中所有其他图像中的相同位置处的像素进行比较.在对图像空间中的所有像素应用均方误差计算之后,识别一组不同的像素,其表示图像中具有变化的颜色值的像素.
我已经比较并存储了两个图像的文件中的相似像素.但是对于12个图像不能这样做.’code’
import java.io.*;
import java.awt.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
class spe
{
public static void main(String args[])
throws IOException
{
long start = System.currentTimeMillis();
int q=0;
File file1 = new File("filename.txt");
/* if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}*/
FileWriter fw = new FileWriter(file1.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
File file= new File("2000.png");
BufferedImage image = ImageIO.read(file);
int width = image.getWidth(null);
int height = image.getHeight(null);
int[][] clr= new int[width][height];
File files= new File("2002.png");
BufferedImage images = ImageIO.read(files);
int widthe = images.getWidth(null);
int heighte = images.getHeight(null);
int[][] clre= new int[widthe][heighte];
int smw=0;
int smh=0;
int p=0;
//CALUCLATING THE SMALLEST VALUE AMONG WIDTH AND HEIGHT
if(width>widthe)
{
smw =widthe;
}
else
{
smw=width;
}
if(height>heighte)
{
smh=heighte;
}
else
{
smh=height;
}
//CHECKING NUMBER OF PIXELS SIMILARITY
for(int a=0;a<smw;a++)
{
for(int b=0;b<smh;b++)
{
clre[a][b]=images.getRGB(a,b);
clr[a][b]=image.getRGB(a,b);
if(clr[a][b]==clre[a][b])
{
p=p+1;
bw.write("\t");
bw.write(Integer.toString(a));
bw.write("\t");
bw.write(Integer.toString(b));
bw.write("\n");
}
else
q=q+1;
}
}
float w,h=0;
if(width>widthe)
{
w=width;
}
else
{
w=widthe;
}
if(height>heighte)
{
h = height;
}
else
{
h = heighte;
}
float s = (smw*smh);
//CALUCLATING PERCENTAGE
float x =(100*p)/s;
System.out.println("THE PERCENTAGE SIMILARITY IS APPROXIMATELY ="+x+"%");
long stop = System.currentTimeMillis();
System.out.println("TIME TAKEN IS ="+(stop-start));
System.out.println("NO OF PIXEL GETS VARIED:="+q);
System.out.println("NO OF PIXEL GETS MATCHED:="+p);
}
}
解决方法:
您可以使用Catalano Framework执行此操作.有几种指标可用于比较图像,包括均方误差.
例:
FastBitmap original = new FastBitmap(bufferedImage1);
FastBitmap reconstructed = new FastBitmap(bufferedImage2);
ObjectiveFidelity o = new ObjectiveFidelity(original, reconstructed);
// Error total
int error = o.getTotalError();
//Mean Square Error
double mse = o.getMSE();
//Signal Noise Ratio
double snr = o.getSNR();
//Peak Signal Noise Ratio
double psnr = o.getPSNR();
所有这些指标都基于以下书籍:计算机成像:数字图像分析和处理 – Scott E Umbaugh.
下一版本(1.3)将包含Derivative SNR.
内容总结
以上是互联网集市为您收集整理的如何使用基于均方误差的基于像素的图像比较度量来比较java中的图像集?全部内容,希望文章能够帮你解决如何使用基于均方误差的基于像素的图像比较度量来比较java中的图像集?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。