- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些对比度非常微弱且有相当多噪点的成像数据,当我使用线性色标显示时,显示效果不佳。在 imageJ 或 photoshop 等成像软件中,有一条色调曲线,可以对其进行调整以非线性方式增强对比度,并有效地拉伸(stretch)某些感兴趣区域的比例以查看更多细节。
作为这种非线性调整参数的最简单情况,@BrianDiggs 指出了 bias
colorRamp
的参数,这仍然需要先前将数据转换为 [0, 1]。我想将非线性比例推广到除 x^gamma
以外的其他泛函,因此下面的函数实际上并没有使用 bias
在 colorRamp
但在数据端进行转换。
我觉得我正在重新发明轮子; R中已经有这样的连续色标工具了吗?
最佳答案
这是一个可能的解决方案,
set.seed(123)
x <- sort(runif(1e4, min=-20 , max=120))
library(scales) # rescale function
curve_pal <- function (x, colours = rev(blues9),
fun = function(x) x^gamma,
n=10, gamma=1)
{
# function that maps [0,1] -> colours
palfun <- colorRamp(colors=colours)
# now divide the data in n equi-spaced regions, mapped linearly to [0,1]
xcuts <- cut(x, breaks=seq(min(x), max(x), length=n))
xnum <- as.numeric(xcuts)
# need to work around NA values that make colorRamp/rgb choke
testNA <- is.na(xnum)
xsanitised <- ifelse(testNA, 0, fun(rescale(xnum)))
# non-NA values in [0,1] get assigned their colour
ifelse(testNA, NA, rgb(palfun(xsanitised), maxColorValue=255))
}
library(gridExtra)
grid.newpage()
grid.arrange(rasterGrob(curve_pal(x, gamma=0.5), wid=1, heig=1, int=F),
rasterGrob(curve_pal(x, gamma=1), wid=1, heig=1, int=F),
rasterGrob(curve_pal(x, gamma=2), wid=1, heig=1, int=F),
nrow=1)
关于r - 具有 Gamma 参数的渐变色标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18036849/
我需要我的 Sprite 从一种颜色过渡到另一种颜色,等等...比如蓝色,然后绿色,然后紫色,但我找不到任何好的 Action ,我想知道,我应该使用动画吗?或者是否有为此采取的联合行动? 最佳答案
我必须做某事。像这样,我无法弄清楚问题是什么。这是我的代码: size(200,200); background(255); float w = 200 ; float radius = 20; wh
我需要更改 Lollipop (API 21) 应用程序中 ProgressBar 元素的颜色。更清楚地说,我的意思是,例如,Youtube 移动应用程序循环进度条。例如,我需要将进度条的颜色设为红色
如何让网站像下面的例子那样改变 Activity 栏的颜色: 最佳答案 在您的网页中添加: 阅读更多 here . 关于android - 如何在 Material Design 中让 Activi
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我是一名优秀的程序员,十分优秀!