forked from tylermorganwall/rayimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
63 lines (47 loc) · 1.83 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
output:
github_document:
html_preview: false
editor_options:
chunk_output_type: console
---
rayfocus
=========================================================
Overview
--------
**rayfocus** is an open source package for rendering a depth of field for images. This is done by using a user-supplied depth map to variably blur the image based on distance, and supports a user-defined focal length, focal distance, and aperture shape.
Installation
------------
``` r
# To install the latest version from Github:
# install.packages("devtools")
devtools::install_github("tylermorganwall/rayfocus")
```
Functions
---------
rayfocus currently has only one function:
`render_bokeh` takes two images as an input: an in-focus image, and a depth map for that image. These can either be in-memory representations of the image, or filepaths to the images. The user can also specify various camera settings, including:
* Focal point
* Focal length
* F-stop
* Aperture shape (including custom aperture shapes passed by the user)
* Aperture rotation
* Bokeh intensity
* Bokeh intensity limit
The output is either plotted to the current device, or save to a file (if a filename is passed to the function).
Usage
-----
The package comes with a sample image and depth map derived from Stanford "dragon" 3D model. The image is in memory as `dragon` and the depthmap is `dragondepth`.
```{r}
#load rayshader package for raster plotting
library(rayshader)
library(rayfocus)
plot_map(dragon)
plot_map(t(dragondepth[nrow(dragondepth):1,])) #re-orient 2D matrix to display correctly
render_bokeh(dragon,dragondepth,focus=0.4,progress=FALSE)
```
We can also adjust the shape of the aperture, as well as the bokeh intensity.
```{r}
render_bokeh(dragon,dragondepth,focus=0.4,focallength = 100,
fstop = 2, bokehshape = "hex", bokehintensity = 5,progress=FALSE)
```