1 2 3 4 5 6 7 8 9 10 11
|
if(size(I,3) == 3)
[DX,DY,~] = gradient(I);
mag = DX .^ 2 + DY .^ 2;
[~,channel] = max(mag,[],3);
dx = DX(:,:, 1) .* (channel == 1) + DX(:,:, 2) .* (channel == 2) + DX(:,:, 3) .* (channel == 3);
dy = DY(:,:, 1) .* (channel == 1) + DY(:,:, 2) .* (channel == 2) + DY(:,:, 3) .* (channel == 3);
complex_g = complex(dx,dy);
else
[dx,dy] = gradient(I);
complex_g = complex(dx,dy);
end
|