我有兴趣在现有图像中添加单个高斯形状的对象,如附图中所示.我想要添加对象的基本图像是8位无符号,值为0-255.附着图像中的明亮物体实际上是由归一化差异植被指数(NDVI)数据表示的树.附件脚本是我到目前为止所拥有的.如何添加一个高斯形状的abject(即树),其值从110到155到现有的NDVI图像?
此处提供的示例数据可与此脚本一起用于计算NDVI

file = 'F:\path\to\fourband\image.tif';
[I R] = geotiffread(file);
outputdir = 'F:\path\to\output\directory\'
%% Make NDVI calculations
NIR = im2single(I(:,:,4));
red = im2single(I(:,:,1));
ndvi = (NIR - red) ./ (NIR + red);
ndvi = double(ndvi);
%% Stretch NDVI to 0-255 and convert to 8-bit unsigned integer
ndvi = floor((ndvi + 1) * 128); % [-1 1] -> [0 256]
ndvi(ndvi < 0) = 0; % not really necessary, just in case & for symmetry
ndvi(ndvi > 255) = 255; % …Run Code Online (Sandbox Code Playgroud) 如何强制表格的尺寸在R中相等?
例如:
a <- c(0,1,2,3,4,5,1,3,4,5,3,4,5)
b <- c(1,2,3,3,3,3,3,3,3,3,5,5,6)
c <- table(a,b)
print(c)
# b
#a 1 2 3 5 6
# 0 1 0 0 0 0
# 1 0 1 1 0 0
# 2 0 0 1 0 0
# 3 0 0 2 1 0
# 4 0 0 2 1 0
# 5 0 0 2 0 1
Run Code Online (Sandbox Code Playgroud)
但是,我正在寻找以下结果:
print(c)
# b
#a 0 1 2 3 4 5 6
# 0 0 1 …Run Code Online (Sandbox Code Playgroud) 检查列表中部分字符串的最有效方法是什么?
例如,假设我在以下列表中查找"4110964_se"(True)或"4210911_sw"(False):
files = ['H:\\co_1m_2013\\41108\\m_4110864_se_12_1_20130717.tif',
'H:\\co_1m_2013\\41108\\m_4110864_sw_12_1_20130717.tif',
'H:\\co_1m_2013\\41109\\m_4110964_se_12_1_20130722.tif']
Run Code Online (Sandbox Code Playgroud)
如果我使用简单的检查,结果不是我所期望的:
>>> "4110964_se" in files
False
Run Code Online (Sandbox Code Playgroud) 附加的脚本对样本变量x,y和z执行等效性测试.
equivalence.xyplot()虽然基本的格子图形很难用,但它确实很方便.如何使用ggplot2绘制这些数据而不是基本点阵图形?
编辑:
例如,using ggplot(plot1)返回以下错误:
错误:ggplot2不知道如何处理类格子的数据
我不知道从哪里开始将格子类数据转换为ggplot2格式.关于将基于格子的图形转换为ggplot2的任何具体建议都将受到赞赏.
require(equivalence)
require(gridExtra)
require(lattice)
x = c(1,4,3,5,3,7,8,6,7,8,9)
y = c(1,5,4,5,3,6,7,6,7,2,8)
z = c(2,4,3,5,4,7,8,5,6,6,9)
mydata = data.frame(x,y,z)
plot1 = equivalence.xyplot(mydata$x~mydata$y,alpha=0.05, b0.ii=0.25, b1.ii=0.25)
plot2 = equivalence.xyplot(mydata$x~mydata$z,alpha=0.05, b0.ii=0.25, b1.ii=0.25)
plot3 = equivalence.xyplot(mydata$y~mydata$z,alpha=0.05, b0.ii=0.25, b1.ii=0.25)
# Combine plots into one figure
grid.arrange(plot1, plot2, plot3, ncol=2)
Run Code Online (Sandbox Code Playgroud)
