image-comparison

简介: image-comparison

人活在世,不过一场美丽的寄居。——简嫃曾

我们可以使用image-comparison来在java中进行两个文件的对比:

项目地址:https://github.com/romankh3/image-comparison

它会自动生成对比后带红框的对比图,还能返回这些正方形的信息

首先引入GAV

<dependency>
    <groupId>com.github.romankh3</groupId>
    <artifactId>image-comparison</artifactId>
    <version>4.4.0</version>
</dependency>

使用:

//load images to be compared:
     BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected.png");
     BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual.png");
     //Create ImageComparison object and compare the images.
     ImageComparisonResult imageComparisonResult = new ImageComparison(expectedImage, actualImage).compareImages();
     //Check the result
     assertEquals(ImageComparisonState.MATCH, imageComparisonResult.getImageComparisonState());

这里是对比俩文件是否相同,在这个imageComparisonResult中还包含了其他的信息,这里就不一一列举了,可以在项目介绍中看到

如果我们要生成对比后的图,用下面的方式即可

//load images to be compared:
       BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected.png");
       BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual.png");
       // where to save the result (leave null if you want to see the result in the UI)
       File resultDestination = new File( "result.png" );
       //Create ImageComparison object with result destination and compare the images.
       ImageComparisonResult imageComparisonResult = new ImageComparison(expectedImage, actualImage, resultDestination).compareImages();

resultDestination也可以传路径

相关文章
HALCON error #1302: Wrong value of control parameter: 2 in operator affine_trans_region
HALCON error #1302: Wrong value of control parameter: 2 in operator affine_trans_region
|
3月前
|
算法 数据挖掘
文献解读-Consistency and reproducibility of large panel next-generation sequencing: Multi-laboratory assessment of somatic mutation detection on reference materials with mismatch repair and proofreading deficiency
Consistency and reproducibility of large panel next-generation sequencing: Multi-laboratory assessment of somatic mutation detection on reference materials with mismatch repair and proofreading deficiency,大panel二代测序的一致性和重复性:对具有错配修复和校对缺陷的参考物质进行体细胞突变检测的多实验室评估
32 6
文献解读-Consistency and reproducibility of large panel next-generation sequencing: Multi-laboratory assessment of somatic mutation detection on reference materials with mismatch repair and proofreading deficiency
|
4月前
|
Python
UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images
本文提供了解决PIL库中"Palette images with Transparency"警告的方法,通过将图片转换为'RGB'模式来消除透明通道的问题。
UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images
|
3月前
|
机器学习/深度学习 存储 算法
latent space
【9月更文挑战第23天】
81 7
|
7月前
|
算法 光互联 计算机视觉
Locally Adaptive Color Correction for Underwater Image Dehazing and Matching
该文提出了一种新颖的水下图像处理方法,结合颜色转移和局部调整来校正颜色,以应对水下光照和散射造成的图像退化。传统颜色转移方法基于全局参数,不适应水下场景中颜色变化的局部性质。文章中,作者通过融合策略,利用光衰减水平估计来实现局部颜色校正。首先,通过暗通道先验恢复彩色补偿图像,然后估计光衰减图。接着,创建一个合成图像,该图像的统计特性代表高衰减区域,用于颜色转移。最后,通过加权融合初始图像和颜色转移图像,生成最终的颜色校正图像。这种方法旨在提高水下图像的对比度和颜色准确性,特别关注高衰减区域。
89 1
|
JavaScript
image-conversion
image-conversion
223 0
|
人工智能 编解码 自然语言处理
论文解读:Inpaint Anything: Segment Anything Meets Image Inpainting
论文解读:Inpaint Anything: Segment Anything Meets Image Inpainting
447 0
|
算法
Multi-scale multi-intensity defect detection in ray image of weld bead
用于检查内部缺陷的射线探伤是一种重要的焊接无损检测技术。不同检测场景、不同类型缺陷的焊道射线照片差异很大,限制了自动检测算法的通用性。
103 0
《AVPASS-Leaking-And-Bypassing-Anitvirus-Detection-Model-Automatically》电子版地址
AVPASS-Leaking-And-Bypassing-Anitvirus-Detection-Model-Automatically
61 0
《AVPASS-Leaking-And-Bypassing-Anitvirus-Detection-Model-Automatically》电子版地址

热门文章

最新文章