recolorize

Simplifying and remapping image colors.

https://github.com/hiweller/recolorize

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: scholar.google
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Simplifying and remapping image colors.

Basic Info
Statistics
  • Stars: 41
  • Watchers: 4
  • Forks: 3
  • Open Issues: 3
  • Releases: 0
Created about 6 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  message = FALSE
)
```

# recolorize v`r devtools::as.package(".")$version`


[![R-CMD-check](https://github.com/hiweller/recolorize/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hiweller/recolorize/actions/workflows/R-CMD-check.yaml)


#### Color-based image segmentation (for people with other things to do).



> Comparison of color maps produced using k-means clustering (center) vs. `recolorize` (right). Original image credits: John E. Randall, Nathan P. Lord, and Alison Davis-Rabosky.

* **Update, Feb. 2024**: Please cite the [article](https://doi.org/10.1111/ele.14378) if you're using this package! (Also, please read the article)
* **Update, Dec. 2021**: recolorize is now [on CRAN](https://cran.r-project.org/package=recolorize)!
* **Update, Sept. 2021**: A methods manuscript is in progress, but in the meantime, if you need to cite this package, please cite [this abstract](https://scholar.google.com/scholar?cluster=7568048124372269297&hl=en&oi=scholarr).

## What is this?

This is a package for making color maps, which are needed (or at least useful) for a wide range of color analysis techniques. It was born out of conversations with many biologists who found, to their surprise and mine, that generating color maps were the bottleneck step in their analyses. Fully automated methods rarely work all of the time, and are difficult to modify, while fully manual methods are subjective and time-consuming. This package tries to split the difference by giving you a mix of tools that will do a pretty good job with no user input, and then allow minor manual changes like merging and filtering layers or splitting components, before exporting them to the next step of your analysis (e.g. [pavo](https://cran.r-project.org/package=pavo), [patternize](https://cran.r-project.org/package=patternize)). It's also, for the most part, totally deterministic  no arbitrary seed-setting for repeatability.

## Quick start

Install the package:

```{r, eval = FALSE}
# development version:
install.packages("devtools")
devtools::install_github("hiweller/recolorize")

# OR
install.packages("recolorize") # CRAN release
```

To run `recolorize` on a single image:

```{r, eval=F}
library(recolorize)

# load an image that comes with the package:
img <- system.file("extdata/corbetti.png", package = "recolorize")
rc <- recolorize2(img, cutoff = 45)
```



A batch processing example:

```{r, eval=F}
# get list of all PNGs that come with the package:
images <- dir(system.file("extdata", package = "recolorize"),
             pattern = ".png", full.names = TRUE)

# for every image...
for (i in 1:length(images)) {

  # get an initial fit with generic clustering
  init_fit <- recolorize2(images[i], method = "hist", bins = 2, cutoff = 25, plotting = FALSE)

  # drop small patches
  refined_fit <- thresholdRecolor(init_fit, pct = 0.01, plotting = FALSE)

  # store in an output variable
  if (i == 1) {
    colormap_list <- list(refined_fit)
  } else {
    colormap_list[[i]] <- refined_fit
  }
}

# compare original to recolored images:
layout(matrix(1:10, nrow = 2, byrow = TRUE))
par(mar = rep(0, 4))
o <- lapply(colormap_list, function(i) plot(i$original_img))
r <- lapply(colormap_list, function(i) plotImageArray(recoloredImage(i)))
```



See [package vignettes](https://cran.r-project.org/package=recolorize/vignettes/Introduction.html) for detailed documentation.

## How does it work?

Recolorize is a toolbox of automatic, semi-automatic, and manual methods that aims to give you reproducible results that work pretty well out-of-box, and which are easy to tailor to your needs. The general workflow is an initial clustering step -> an automatic or semi-automatic reclustering step -> optional manual refinements -> export to another format, like an image, a set of binary masks, or another R package.

## Contact

Please do email me if this is something that may be relevant for you or if you have questions. Most of the features in the package are the result of feedback, and no method should be developed in a vacuum. If you include example images in your email, my likelihood of responding goes through the roof.

Email: hannahiweller@gmail.com

Owner

  • Name: Hannah Weller
  • Login: hiweller
  • Kind: user

Graduate student at Brown University, studying how behavior ↔ morphology. I like coding almost as much as I like fish.

GitHub Events

Total
  • Watch event: 3
  • Push event: 8
Last Year
  • Watch event: 3
  • Push event: 8

Packages

  • Total packages: 1
  • Total downloads:
    • cran 393 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: recolorize

Color-Based Image Segmentation

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 393 Last month
Rankings
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Average: 46.9%
Downloads: 75.4%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.50 depends
  • abind * imports
  • colorRamps * imports
  • grDevices * imports
  • graphics * imports
  • imager * imports
  • mgcv * imports
  • pavo * imports
  • plot3D * imports
  • plotfunctions * imports
  • png * imports
  • raster * imports
  • stats * imports
  • knitr * suggests
  • rmarkdown * suggests
  • smoothr * suggests
  • sp * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite