improfile 関数にて、2点の座標を入力引数に与えることで、指定した2点を結ぶ画素値の列ベクトルを得ることが
できます。
>> c = improfile(I,x,y)
ここで、x,yは、共に行ベクトルとなります。x,y はそれぞれx軸方向,y軸方向の座標を指定します。
例) 座標(10,200),(240,200) を結び、画像情報を取得
I = imread('cameraman.tif'); % 画像読み込み
x = [10 240]; y = [200 200]; % 2点の座標の定義
c = improfile(I,x,y); % 画素値の取得
imshow(I),axis on
hold on, plot(x,y,'*-')
figure,plot(c) % 画素値のプロット

