我正在关注Coursera上的数据科学课程,我有一个关于其中一个分配的问题,我必须反转矩阵,然后缓存该结果.
基本上我一直在谷歌搜索,我找到了答案,但有部分答案,我还不明白.出于这个原因,我不想提交我的作业,因为我不想提交任何我不完全理解的内容.
我从下面的代码中无法理解的部分是定义setInverse的部分.'function(inverse)inv'来自哪里?特别是'逆'从未被定义过?
在此之后返回一个对我来说没有多大意义的列表?
如果有人可以花时间向我解释这个功能,我将非常感激!
makeCacheMatrix <- function(x = matrix()) {
inv <- NULL
set <- function(y) {
x <<- y
inv <<- NULL
}
get <- function() x
setInverse <- function(inverse) inv <<- inverse
getInverse <- function() inv
list(set = set,
get = get,
setInverse = setInverse,
getInverse = getInverse)
}
## Write a short comment describing this function
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inv <- x$getInverse()
if (!is.null(inv)) …Run Code Online (Sandbox Code Playgroud) 我一直在使用 OpenCV 和 Python 执行一些图像操作。我设法隔离了我感兴趣的轮廓。现在我有两张图像,一张 NDVI 图像和一张普通图像。我想用我的面具将两者合并。因此,如果我的蒙版的像素位置为零,则应使用图像一的像素;如果蒙版的像素位置为 1,则应使用图像二的像素。基于此,我想合并我的两张照片。
任何建议,将不胜感激 :)!