Skip to content

Gaussian Blur inconsistency with PIL #2239

@Sjmarf

Description

@Sjmarf

I've noticed that performing a gaussian blur with pygame.transform.gaussian_blur makes a less blurry image than PIL's gaussian blur when the same radius is used. If the radius of the pygame blur is doubled, then they match up correctly.

I assume this isn't intended behaviour? Is it possible that the radius was not doubled by Pygame CE when it should have been, or something like that?

Blurring a pygame surface with PIL:

img = Image.frombytes(
    "RGBA", surface.get_size(), pygame.image.tostring(surface "RGBA", False)
)
img = img.filter(ImageFilter.GaussianBlur(radius=10))
blurred_surface = pygame.image.frombuffer(
    img.tobytes(), img.size, "RGBA"
)

With Pygame CE:

blurred_surface = pygame.transform.gaussian_blur(surface, 10)

Side-by-side comparison, with both radii set to 10:

Both radii set to 10:

PIL with a radius of 10, and Pygame with a radius of 20:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions