matlab里求矩阵的梯度用什么语句
2个回答
展开全部
matlab里求矩阵的梯度使用的语句,代码如则坦山下:
(Matlab环孙中境下)
Gradx = [1 -1];
Grady = [1 -1];
ConX = zeros(ROW,COL);
ConY = zeros(ROW,COL);
for row = 2:ROW
for col = 2:COL
Cellx = [I(row,col-1) I(row,col)];
Celly = [I(row-1,col) I(row,col)];
ConX(row,col) = sum(sum(double(Gradx).*double(Cellx)));
ConY(row,col) = sum(sum(double(Grady).*double(Celly)));
end
end
Grad(:,:,1) = ConX; % x方向梯信没度
Grad(:,:,2) = ConY; % y方向梯度
(Matlab环孙中境下)
Gradx = [1 -1];
Grady = [1 -1];
ConX = zeros(ROW,COL);
ConY = zeros(ROW,COL);
for row = 2:ROW
for col = 2:COL
Cellx = [I(row,col-1) I(row,col)];
Celly = [I(row-1,col) I(row,col)];
ConX(row,col) = sum(sum(double(Gradx).*double(Cellx)));
ConY(row,col) = sum(sum(double(Grady).*double(Celly)));
end
end
Grad(:,:,1) = ConX; % x方向梯信没度
Grad(:,:,2) = ConY; % y方向梯度
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询