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

document the difference between float32 and Float32, etc. #146

Open
wants to merge 1 commit into
base: source
Choose a base branch
from

Conversation

mgautam98
Copy link
Collaborator

Solves #139
Added documentation to advertise the usage of lower-cased forms of Float32, Float64 etc

@mgautam98 mgautam98 linked an issue Jul 1, 2020 that may be closed by this pull request
@mgautam98 mgautam98 requested a review from timholy July 1, 2020 07:17
Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! I opened that issue as a memo to myself but apparently you're handling it rather eagerly.

It's really nice to see these improvements in the documentation.

docs/src/tutorials/conversions_views.md Outdated Show resolved Hide resolved
docs/src/tutorials/conversions_views.md Outdated Show resolved Hide resolved
docs/src/tutorials/conversions_views.md Outdated Show resolved Hide resolved
docs/src/tutorials/conversions_views.md Outdated Show resolved Hide resolved
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great idea, thanks for tackling this.

docs/src/tutorials/conversions_views.md Outdated Show resolved Hide resolved
docs/src/tutorials/conversions_views.md Outdated Show resolved Hide resolved
@mgautam98 mgautam98 force-pushed the document-float32 branch 2 times, most recently from d513c22 to 85f1cab Compare July 2, 2020 04:41
[...]
```
**Note**: `Float64.(rgb_img)` throws error because it does not implicitly
convert RGB to single channel but `float64.(rgb_img)` works as expected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Works as expected" depends entirely on what your expectations are. Some people will expect it to return a single floating-point number.

How about copy/pasting the examples with a single colorant object that I gave in my explanation to you? This mixes together broadcasting with colorspace conversion, and we don't have to mix the concepts.

@johnnychen94
Copy link
Member

johnnychen94 commented Jul 2, 2020

I'd like to also add the following table into the document as a cheat sheet:

The following table tells you how you can convert from a number/colorant to another number/colorant

from \ to N0f8 Float32 Gray{N0f8} Gray{Float32} RGB{N0f8} RGB{Float32}
N0f8 - float32(c) Gray(c) Gray{Float32}(c) RGB(c) RGB{Float32}(c)
Float32 N0f8(c) - Gray{N0f8}(c) Gray(c) RGB{N0f8}(c) RGB(c)
Gray{N0f8} N0f8(c) Float32(c) - float32(c) RGB(c) RGB{Float32}(c)
Gray{Float32} N0f8(c) Float32(c) n0f8(c) - RGB{N0f8}(c) RGB(c)
RGB{N0f8} N0f8(Gray(c)) Float32(Gray(c)) Gray(c) Gray{Float32}(c) - float32(c)
RGB{Float32} N0f8(Gray(c)) Float32(Gray(c)) Gray{N0f8}(c) Gray(c) RGB{N0f8}(c) -
  • float32(RGB(c)) works equivelently to RGB{Float32}(c), and their performances are the same, too.
  • the lowercase function also works if c is a type, for example, float32(Gray{N0f8}) gives you Gray{Float32}
  • To handle image data, you just need to broadcast it, for example, float32.(img)

Or maybe a simplified version by removing the explicit construction ones:

from \ to N0f8 Float32 Gray{N0f8} Gray{Float32} RGB{N0f8} RGB{Float32}
N0f8 - float32(c) Gray(c) - RGB(c) -
Float32 n0f8(c) - - Gray(c) - RGB(c)
Gray{N0f8} - - - float32(c) RGB(c) -
Gray{Float32} - - n0f8(c) - - RGB(c)
RGB{N0f8} N0f8(Gray(c)) Float32(Gray(c)) Gray(c) - - float32(c)
RGB{Float32} N0f8(Gray(c)) Float32(Gray(c)) - Gray(c) - -

I personally like the simplified version because it shows all the convenient way of converting things in JuliaImages.

@timholy will the usage of RGB(1.0) being deprecated? I believe it will still be available?

@mgautam98
Copy link
Collaborator Author

@johnnychen94 this cheat-sheet is really helpful.

@johnnychen94 johnnychen94 added the best practice workflows and best practice that are useful in JuliaImages and/or Julia label Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
best practice workflows and best practice that are useful in JuliaImages and/or Julia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document the difference between float32 and Float32, etc.
3 participants