Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing Luma+alpha image on ARM (Apple) causes stripe artifacts #49

Open
MichaelGrupp opened this issue Mar 17, 2025 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@MichaelGrupp
Copy link

Hi,

thanks for this nice library. I noticed an issue with LA8 grayscale images that have an alpha channel on ARM, specifically Apple Silicon (I used M1 & M4). With the NEON extensions that are enabled by default, the resized LA8 image has stripes. Disabling NEON removes those stripes. The issue also doesn't seem to affect RGB, RGBA8 or L8; these can be resized with NEON in my tests. Haven't tested LA16.

Here is an example using dummy images created with Gimp: one LA8 image and an RGBA8 image.

This can be reproduced using the resizer example from the main branch (a472768):

cargo run -p resizer <image> -h 50% -w 50%
Original Resized with NEON
Image Image
Image Image

I didn't dig deeper than that, for my personal project it was sufficient to convert to RGBA8 to "fix" the issue. I also don't know if this only an issue on Apple Silicon or also on other ARM platforms.

@MichaelGrupp MichaelGrupp changed the title Resizing Luma+alpha image cause Resizing Luma+alpha image causes stripe artifacts Mar 17, 2025
@MichaelGrupp MichaelGrupp changed the title Resizing Luma+alpha image causes stripe artifacts Resizing Luma+alpha image on ARM (Apple) causes stripe artifacts Mar 17, 2025
MichaelGrupp added a commit to MichaelGrupp/maps that referenced this issue Mar 17, 2025
The issue doesn't affect RGBA8 and others. Since all images are
now anyway converted to RGBA8 in this app, we don't run into
this problem anymore currently.

See: Cykooz/fast_image_resize#49
MichaelGrupp added a commit to MichaelGrupp/maps that referenced this issue Mar 17, 2025
The issue doesn't affect RGBA8 and others. Since all images are
now anyway converted to RGBA8 in this app, we don't run into
this problem anymore currently.

See: Cykooz/fast_image_resize#49
MichaelGrupp added a commit to MichaelGrupp/maps that referenced this issue Mar 18, 2025
The issue doesn't affect RGBA8 and others. Since all images are
now anyway converted to RGBA8 in this app, we don't run into
this problem anymore currently.

See: Cykooz/fast_image_resize#49
@Cykooz Cykooz self-assigned this Mar 18, 2025
@Cykooz Cykooz added the bug Something isn't working label Mar 18, 2025
MichaelGrupp added a commit to MichaelGrupp/maps that referenced this issue Mar 18, 2025
The issue doesn't affect RGBA8 and others. Since all images are
now anyway converted to RGBA8 in this app, we don't run into
this problem anymore currently.

See: Cykooz/fast_image_resize#49
@awxkee
Copy link

awxkee commented Mar 18, 2025

unsafe fn multiply_alpha_row(src_row: &[U8x2], dst_row: &mut [U8x2]) {
    let src_chunks = src_row.chunks_exact(32);
    let src_remainder = src_chunks.remainder();
    let mut dst_chunks = dst_row.chunks_exact_mut(32);

to

unsafe fn multiply_alpha_row(src_row: &[U8x2], dst_row: &mut [U8x2]) {
    let src_chunks = src_row.chunks_exact(16);
    let src_remainder = src_chunks.remainder();
    let mut dst_chunks = dst_row.chunks_exact_mut(16);

if that makes sense.

P.S. NEON is mandatory extension on Aarch64, #[target_feature(enable = "neon")] is enforced on all code which target is Aarch64.

@Cykooz
Copy link
Owner

Cykooz commented Mar 18, 2025

Thank you for report.
I won't be able to fix this problem for the next two weeks because I'm on holiday. But after that I'll take care of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants