This seems rather simple. First, project your data to a single dimension, say your image is called data_2D,
data_1D = sum(data_2D,1);
This will sum all the elements of each column/row. Then you want to avoid the noise so threshold above a certain level, say 5 and use find to locate first and last points
Then you can insert that in between a loop that will process all your data sets.
Hope this solves your problem. If it does, please accept the answer, if it does not, let me know.