qa_cli: increase to 1200dpi + use 1 pixel erosion in comparisons to golden sample
This commit is contained in:
parent
96a34e5b57
commit
d5fc2b757d
Binary file not shown.
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 747 KiB |
|
@ -28,7 +28,7 @@ from pathlib import Path
|
||||||
import pytest
|
import pytest
|
||||||
from typing import List
|
from typing import List
|
||||||
import platform
|
import platform
|
||||||
from PIL import Image, ImageChops
|
from PIL import Image, ImageChops, ImageFilter
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def images_are_equal( image1: str, image2: str ):
|
def images_are_equal( image1: str, image2: str ):
|
||||||
|
@ -45,13 +45,27 @@ def images_are_equal( image1: str, image2: str ):
|
||||||
retval = True
|
retval = True
|
||||||
|
|
||||||
if sum != 0.0:
|
if sum != 0.0:
|
||||||
norm_sum = sum / np.sqrt( sum )
|
# images are not identical - lets allow 1 pixel error difference (for curved edges)
|
||||||
retval = norm_sum < 0.001
|
|
||||||
|
|
||||||
if not retval:
|
|
||||||
diff = ImageChops.difference( image1, image2 )
|
diff = ImageChops.difference( image1, image2 )
|
||||||
diff_name = image1.filename + ".diff.png"
|
diffgray=diff.convert("L")
|
||||||
diff.save( diff_name )
|
diffThresholded=diffgray.point(lambda x: 255 if x > 1 else 0)
|
||||||
|
diffBinary=diffThresholded.convert("1")
|
||||||
|
|
||||||
|
# erode binary image by 1 pixel
|
||||||
|
diffEroded = diffBinary.filter(ImageFilter.MinFilter(3))
|
||||||
|
|
||||||
|
erodedSum = np.sum( np.asarray ( diffEroded ).astype( np.float32 ) )
|
||||||
|
|
||||||
|
retval = erodedSum == 0
|
||||||
|
|
||||||
|
if not retval:
|
||||||
|
diff_name = image1.filename + ".diff1.png"
|
||||||
|
diff.save( diff_name )
|
||||||
|
diffEroded_name = image1.filename + ".diffEroded_erodedsum" + str(erodedSum)+ ".png"
|
||||||
|
diffEroded.convert("RGB")
|
||||||
|
diffEroded.save( diffEroded_name )
|
||||||
|
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
@ -93,7 +107,7 @@ def test_sch_export_svg( kitest,
|
||||||
|
|
||||||
compare_file_path = kitest.get_data_file_path( compare_fn )
|
compare_file_path = kitest.get_data_file_path( compare_fn )
|
||||||
|
|
||||||
cairosvg.svg2png( url=str( output_svg_path ), write_to=str( png_converted_from_svg_path ), dpi=300 )
|
cairosvg.svg2png( url=str( output_svg_path ), write_to=str( png_converted_from_svg_path ), dpi=1200 )
|
||||||
|
|
||||||
assert images_are_equal( png_converted_from_svg_path, compare_file_path )
|
assert images_are_equal( png_converted_from_svg_path, compare_file_path )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue