Problem
You have a 2D matrix. You used the Loc function to locate interesting elements, but Loc returned indexes for a 1D matrix. How can you convert the 1D indexes back to 2D indexes?
Solution
You'll need to use the Floor and Mod functions and you'll need to know the number of columns in your 2D matrix. Here's the three lines, buried in the commented example below. pixmat is a 2D matrix, Loc is finding the non-zero pixels, which are black:
blacklocs = (Loc( pixmat ) - 1); // blacklocs is a matrix of 1D indexes (0-based)
rowlocs = Floor( (blacklocs) / nc ) + 1; // nc is the number of columns in the 2D pixmat
collocs = Mod( (blacklocs), nc ) + 1; // rowlocs and collocs are 2D indexes (1-based)
textbox = Text Box( "Gargoyle", <<setfontsize( 20 ) );
picture = textbox << getpicture;
pixmat = picture << getpixels("r");
pixmat = pixmat[1];
pixmat = pixmat < .75;
nr = N Rows( pixmat );
nc = N Cols( pixmat );
blacklocs = (Loc( pixmat ) - 1);
rowlocs = Floor( (blacklocs) / nc ) + 1;
collocs = Mod( (blacklocs), nc ) + 1;
scale = 16;
New Window( "Example",
Graph Box(
framesize( nc * scale, nr * scale ),
<<Marker Size( scale * .65 ),
xaxis( {Min( -1 ), Max( nc + 1 )} ),
yaxis( {Min( nr + 1 ), Max( -1 )} ),
Marker( collocs, rowlocs )
)
);
Pixels from a bitmap, displayed as markers in a graph
Discussion
The -1 and +1 are important, don't leave them out. Read the 1-based and 0-based comments in the JSL.
The text in the bitmap is anti-aliased, which means the edge pixels are shades of gray proportional to how the perfect edge of the character would have fallen between pixels. I chose a gray threshold of .75 because I liked the result better than .5; your application probably won't be dealing with that at all.
JMP's Shape() function converts the shape of a matrix. That won't help here.
Many of the statements in the example are operating on a matrix without using an explicit JSL for-loop. Good for speed.
See Also
https://www.jmp.com/support/help/14-2/matrix-functions.shtml