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

Change (color)view arguments? #132

Closed
jvanlunenburg opened this issue Jun 28, 2020 · 2 comments · Fixed by #134
Closed

Change (color)view arguments? #132

jvanlunenburg opened this issue Jun 28, 2020 · 2 comments · Fixed by #134
Assignees

Comments

@jvanlunenburg
Copy link

jvanlunenburg commented Jun 28, 2020

I think colorview(A, C) would facilitate piping if there is a set default parameter.
E.g. let's say C has a sensible default type based on size(channelview(A),1), we could then do:

img = load("mandrill") |> channelview |> modifyelements |> colorview

As I understand the pipe operator in base Julia needs single argument functions, and all views will always need an image, but parameters (if any) may be optional. So it makes sense to make A the first argument for all views. Is there a reason for the apparent convention:
viewfunction(parameter, image, other_parameters)?

@timholy
Copy link
Member

timholy commented Jun 28, 2020

I'm a bit reluctant to have "sensible defaults" based on array sizes. If someone snips out a 3x3x3 block of a 3d grayscale image and then passes it through a pipeline that includes colorview, it will behave radically differently than snipping out a 4x4x4 block.

The color type is first colorview(RGB, img) rather than last because it's a lot like reinterpret(T, A) or convert(T, A). https://docs.julialang.org/en/latest/manual/style-guide/#Write-functions-with-argument-ordering-similar-to-Julia-Base-1

You can always make a 1-arg function like this:

img = load("mandrill") |> channelview |> modifyelements |> A->colorview(RGB, A)

@johnnychen94
Copy link
Member

johnnychen94 commented Jun 28, 2020

Similar to JuliaImages/ImageBinarization.jl#68, we could introduce a curried form of colorview so that colorview(T) returns a function.

This makes the pipeline nicer 😄

img = load("mandrill") |> channelview |> modifyelements |> colorview(RGB)

Though, there seems to be some discussion and inconsistency of "what function should have curried form?": JuliaLang/julia#33193

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 a pull request may close this issue.

3 participants