Skip to content

Instantly share code, notes, and snippets.

@DrNickRedfern
Last active September 8, 2022 07:58
Show Gist options
  • Save DrNickRedfern/a6092ae449ae0673c8122781fdb3e221 to your computer and use it in GitHub Desktop.
Save DrNickRedfern/a6092ae449ae0673c8122781fdb3e221 to your computer and use it in GitHub Desktop.
An illustration of vectorisation in R
# The red colour channel of an image using the [0, 1] scale
RED <- c(1.000 0.259 0.557 0.329 1.000 0.259 0.263 0.263 1.000 0.263)
# Convert RED to the [0, 255] scale by multiplying by 255
red <- RED * 255
# Inspect the rescaled object red
red
[1] 255.000 66.045 142.035 83.895 255.000 66.045 67.065 67.065 255.000 67.065
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment