As you see,I can Farmed the diagonal element:
mat = RandomInteger[20, {13, 17}];
pos = Graphics[Line[{{1, 1}, a = Dimensions[mat]}]] //
Rasterize[#, ImageSize -> Max[a]] & // ImageCrop //
Binarize[#, Mean[#] < 0.99 &] & // Thinning //
PixelValuePositions[#, 1] & //
DeleteCases[#, _?(#[[1]] > a[[1]] || #[[2]] > a[[2]] &)] &;
MapAt[Framed, mat, pos] // TableForm
But I think the method is too ugly.Anyone can give a more beautiful programme?
And I can Framed the element which is in a approximate connectional line between any two position by Image-Tool:
mat = RandomInteger[5, {7, 18}];
pic = mat // Image[#, ImageSize -> Large] & // ImageAdjust
We can get the mask with Image-Tool like this:

And we crop it
So we get the result:
pos = Position[mask // ImageData, 1];
MapAt[Framed, mat, pos] // MatrixForm
But we can find a bug in this method
So we miss a frame in the result.And we cannot build a function like FramedInLine[{1,5},{6,15}],Because of the use of Image-Tool.Anybody can help me?






Bresenham's. A very common topic in computer graphics – Dr. belisarius Nov 26 '15 at 17:36