MATLAB: Chain code for line

chain code

here is my question : in this image which I have attached , starting from (x,y) or (s,t)how can I write the chain code for the line ? what is proper idea to write its code ? a lot of thank for everyone help me or try to help .