View source: R/thresholdRecolor.R
| thresholdRecolor | R Documentation |
Drops color patches whose cumulative sum (as a proportion of total pixels
assigned) is equal to or less than pct, so that only the dominant
color patches remain, and refits the object with the reduced set of
color centers Useful for dropping spurious detail colors.
thresholdRecolor(recolorize_obj, pct = 0.05, plotting = TRUE, ...)
recolorize_obj |
An object of class |
pct |
The proportion cutoff (0-1) for dropping color patches. The higher this value is, the more/larger color centers will be dropped. |
plotting |
Logical. Plot the results? |
... |
Further arguments passed to imposeColors, which is called for refitting a new recolorize object for the reduced set of clusters. |
This function is fairly simple in execution: the color centers are
arranged by their sizes, largest to smallest, and their cumulative sum is
calculated. The minimum number of color centers to reach a cumulative sum
equal to or greater than the cutoff (1 - pct) is retained, and these
dominant colors are used to re-fit the image. Despite being
straightforward, this can be a surprisingly useful function.
A recolorize object.
img <- system.file("extdata/fulgidissima.png", package = "recolorize")
init_fit <- recolorize(img, bins = 3)
thresh_fit <- thresholdRecolor(init_fit, pct = 0.1)
# if you take it too far, you just get one color back:
thresh_fit_oops <- thresholdRecolor(init_fit, pct = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.