fortplot_rendering_comparison Module

Enhanced rendering comparison framework for detecting visual regressions

This module provides systematic comparison tools for PNG/PDF outputs to identify specific rendering differences between commits or versions.

= Key Features = - Pixel-level difference analysis for raster formats - Statistical similarity metrics (MSE, SSIM, histogram comparison) - Visual similarity assessment using perceptual models - Performance optimization for large image comparisons - Comprehensive test coverage for regression detection

= Comparison Modes = - PIXEL_DIFF: Direct pixel-by-pixel comparison - STATISTICAL: Mean squared error and correlation analysis - HISTOGRAM: Color distribution comparison - PERCEPTUAL: Human-vision-weighted similarity metrics

= Usage Examples = ! Basic pixel difference result = compare_png_images("reference.png", "current.png", PIXEL_DIFF)

! Statistical analysis with threshold result = compare_with_threshold("ref.png", "test.png", 0.95_wp)

! Batch comparison for regression testing call run_regression_suite("reference_dir/", "current_dir/", results)



Derived Types

type, public ::  comparison_mode_t

Components

Type Visibility Attributes Name Initial
integer, public :: mode

type, public ::  comparison_result_t

Components

Type Visibility Attributes Name Initial
logical, public :: passed
character(len=512), public :: message
real(kind=wp), public :: similarity_score
real(kind=wp), public :: mse_value
real(kind=wp), public :: ssim_value
real(kind=wp), public :: histogram_correlation
integer, public :: different_pixels
integer, public :: total_pixels
type(comparison_mode_t), public :: mode_used

Functions

public function compare_png_images(reference_path, current_path, mode) result(comparison)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: reference_path
character(len=*), intent(in) :: current_path
type(comparison_mode_t), intent(in) :: mode

Return Value type(comparison_result_t)

public function compare_pdf_files(reference_path, current_path) result(comparison)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: reference_path
character(len=*), intent(in) :: current_path

Return Value type(comparison_result_t)

public function compare_with_threshold(reference_path, current_path, threshold) result(comparison)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: reference_path
character(len=*), intent(in) :: current_path
real(kind=wp), intent(in) :: threshold

Return Value type(comparison_result_t)

public function calculate_similarity_metrics(reference_path, current_path) result(metrics)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: reference_path
character(len=*), intent(in) :: current_path

Return Value type(comparison_result_t)

public function optimize_comparison_performance(width, height, mode) result(should_optimize)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: width
integer, intent(in) :: height
type(comparison_mode_t), intent(in) :: mode

Return Value logical


Subroutines

public subroutine run_regression_suite(reference_dir, current_dir, results)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: reference_dir
character(len=*), intent(in) :: current_dir
type(comparison_result_t), intent(out), allocatable :: results(:)

public subroutine generate_diff_image(reference_path, current_path, diff_output_path)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: reference_path
character(len=*), intent(in) :: current_path
character(len=*), intent(in) :: diff_output_path