Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add support for block pixel enum in ImageBuffer#1919

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
bfraboni wants to merge1 commit intoimage-rs:main
base:main
Choose a base branch
Loading
frombfraboni:block-pixel-enum-support

Conversation

@bfraboni
Copy link

@bfrabonibfraboni commentedApr 30, 2023
edited
Loading

Hey team,

I'm very new to Rust, and very new to using the Image-rs crate -- so please forgive the potential mistakes I could write/say.

I'm trying to add a block enumerator for incoherent ImagBuffer access.
This is usually faster than regular pixel enum when we want to perform a column-major operation on a image, even though the memory layout is row-major.
Basically the following code:

fntranspose_enum<P,Container>(input:&ImageBuffer<P,Container>,output:&mutImageBuffer<P,Container>)whereP:Pixel,Container:Deref<Target =[P::Subpixel]> +DerefMut{for(x, y, pix)in input.enumerate_pixels(){       output.put_pixel(y, x,*pix);}}

can be outperformed by the PR modified version:

fntranspose_enum_blocks<P,Container>(input:&ImageBuffer<P,Container>,output:&mutImageBuffer<P,Container>,block_size:u32)whereP:Pixel,Container:Deref<Target =[P::Subpixel]> +DerefMut{for(x, y, pix)in input.enumerate_pixels_blocks(block_size){        output.put_pixel(y, x,*pix);}}

On my old 2016 laptop I get between 1.3x to 2x perf improvements for some adequate block sizes when tranposing 2K - 4K and 8K images. I still didn't properly becnhmarked on my desktop machine though (Ryzen 7 5800x) but will soon do.

Let me know if that's of interest for the image crate, and please let me know of any dumb mistake I could have done in the code. Note that I randomly chose function and variable names, but we can completely change that, and I can also make a mutable version of the enumerator.

I license past and future contributions under the dual MIT/Apache-2.0 license,
allowing licensees to choose either at their option.

… pixel enum for non consistent memory access for e.g. image transpose
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@bfraboni

[8]ページ先頭

©2009-2025 Movatter.jp