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

Draft: streamify View API #348

Closed
wants to merge 8 commits into from

Conversation

minnerbe
Copy link
Contributor

As discussed with @tpietzsch, this is an attempt to create an API for View that's similar to Java streams. The goal would be to allow this kind of syntax:

Img<?> img = ...
Img<?> changedImg =  img.view()
		.translate(1, 2)
		.expandValue(new DoubleType(0), 1, 1)
		.permute(0, 1)
		.collect();

This is still work in progress. One particular limitation I encountered so far is that most methods in Views map RandomAccessibleInterval into RandomAccessible, i.e., they leave their domain, which makes daisy-chaining impossible.

@tpietzsch
Copy link
Member

I made a variation with multiple ...View interfaces and wrappers in https://github.com/imglib/imglib2/tree/draft/streamify-views.

Usable like this:

RandomAccessibleInterval< IntType > img = ArrayImgs.ints( 100, 100 );
RandomAccess< IntType > access = img.view()
.extendBorder()
.interpolate( new NLinearInterpolatorFactory<>() )
.raster()
.interval( img )
.randomAccess();
Cursor< IntType > cursor = img.view()
.interval( img )
.cursor();

@minnerbe
Copy link
Contributor Author

I added a rough draft for converting a RaiView to an ArrayImg. I probably made some errors while trying to wrestle the generic type of the view into a NativeType, but it seems to work for a small test example.
What do you say, @tpietzsch?

@tpietzsch
Copy link
Member

There is an update version of this PR in #364

@tpietzsch tpietzsch closed this May 8, 2024
@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/recent-and-upcoming-imglib2-improvements/96083/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants