Matlab 获取中心像素';s梯度方向
如何利用matlab获得中心像素梯度方向下的局部像素值Matlab 获取中心像素';s梯度方向,matlab,image-processing,Matlab,Image Processing,如何利用matlab获得中心像素梯度方向下的局部像素值 我已经找到了函数imgradient(),这很好,但是如何在这个角度下将角度转换为直线呢?所以你想知道如何定义一条直线,给定一个点(x0,y0)和一个角度θ?也许是这样的: % T determines the length of the line. I am using a step size % of 0.5 since it should get each pixel. You could always go finer % and
我已经找到了函数imgradient(),这很好,但是如何在这个角度下将角度转换为直线呢?所以你想知道如何定义一条直线,给定一个点
(x0,y0)
和一个角度θ
?也许是这样的:
% T determines the length of the line. I am using a step size
% of 0.5 since it should get each pixel. You could always go finer
% and let the call to unique get rid of the duplicates.
t = 0:0.5:T;
p = unique( round( [x0+t(:)*cos(theta), y0+t(:)*sin(theta) ] ), 'rows' );
上面的p
将是一个像素坐标的Nx2数组,该像素坐标位于从(x0,y0)
开始并延伸出角度θ的直线下方(技术上在1/2 a像素范围内)