1

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

enter image description here

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

enter image description here

We can get the mask with Image-Tool like this: enter image description here

And we crop it

enter image description here

So we get the result:

pos = Position[mask // ImageData, 1];
MapAt[Framed, mat, pos] // MatrixForm

enter image description here

But we can find a bug in this method

enter image description here

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?

yode
  • 26,686
  • 4
  • 62
  • 167

1 Answers1

2
dims = {13, 17};
mat = RandomInteger[20, {13, 17}];
cols = Flatten@ Reverse[Ordering[#, 1] & /@  ImageData[
          ColorConvert[ImageResize[Graphics[Line[{{1, 1}, dims}]], dims], "Grayscale"]]];
pos = Thread[Transpose[{cols, Range@Length@cols}] -> k] /. k -> {Bold, Red};
Grid[mat, ItemStyle -> {Automatic, Automatic, pos}]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453