这里没有机器学习者!在
我正在尝试规范化R中的图像,因为我计划将它们提交到R中的机器学习野生动物图像分类(MLWIC)包中进行分类
该软件包的作者提到,在对图像进行分类之前,应该将它们的大小调整为256 x 256像素(非常容易),然后进行标准化。他们引用了本附录中可用的方法(Norouzzadeh et al 2018,code here))。在
简言之,规范化过程是使用python命令执行的,对于图像中的每个颜色通道,“减去平均值并除以像素的方差”。在
他们使用的python函数的文档tf.image.per_image_standardization()声明:Linearly scales image to have zero mean and unit variance.
This op computes (x - mean) / adjusted_stddev, where mean is the average of all values in image, and adjusted_stddev = max(stddev, 1.0/sqrt(image.NumElements())).
如果我试图在R中复制此过程。然而,当我试图在R中重写tf.image.per_image_standardization()函数时,它会将图像从每个颜色通道中的范围[0,1]更改为例如-1.85到1.85的范围。结果图像看起来不像上面链接的附录中显示的饱和图像。在
原图如下:
这是经过处理的图像,它看起来应该是:
我尝试过的代码:library(imager)
library(tidyverse)
ante
plot(ante)
normalize
ante %>%
imsplit("c") %>%
modify_at(1, normalize) %>%
modify_at(2, normalize) %>%
modify_at(3, normalize) %>%
imappend("c") %>%
plot()
我也尝试了以下方法,得到的图像看起来比原始图像更饱和,但它没有使用均值或标准差。。。在
^{pr2}$
我做错什么了?