comp_backgrad.m

来自「this is a very very very nice code」· M 代码 · 共 30 行

M
30
字号
%This function computes the backward difference or forward difference,
%depending on the value of input variable "type". Mask defines the regions
%to be computed, and wind defines the search space.
function [fyb, fxb] = comp_backgrad_test(IM,pix_set,type)
    
    if type == 1
        %Compute the backward difference. Note that I use the convention
        %that the "forward" direction is from the bottom of the image to
        %the top of the image
        fxb = zeros(size(IM));
        fyb = zeros(size(IM));
        for k = 1:size(pix_set,1)
            y = pix_set(k,1);
            x = pix_set(k,2);
            fyb(y,x) = IM(y,x) - IM(y+1,x);
            fxb(y,x) = IM(y,x) - IM(y,x-1);
        end
    else
        %Compute the forward difference. Note that I use the convention
        %that the "forward" direction is from the bottom of the image to
        %the top of the image
        fxb = zeros(size(IM));
        fyb = zeros(size(IM));
        for k = 1:size(pix_set,1)
            y = pix_set(k,1);
            x = pix_set(k,2);
            fyb(y,x) = IM(y-1,x) - IM(y,x);
            fxb(y,x) = IM(y,x+1) - IM(y,x);
        end
    end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?