Every pixel position is given by meshgrid
[rows, columns, numberOfColorChannels] = size(yourImage);
[x, y] = meshgrid(1:rows, 1:columns);
You most likely don't need that. If you want to find the two points in the image that are fartest apart, you need to use bwboundaries to get a list of boundary coordinates, then use a nested for loop to calculate which pair of points have the greatest distance between them. This is exactly what my attached demo (below the image) does.
See the red line below:
That red line goes between the farthest points in the binary image. The magenta line is the line at the midpoint that is perpendicular to it.