I figured out how to do this based on the second peak in the histogram. It feels kind of hackish and unwieldy, but it works.
Assuming MZ is your two dimensional image:
hist = imhist(MZ);
% Get counts and bins for histogram
[counts, binlocs] = imhist(MZ);
% Find peaks of histogram
[peaks,locs] = findpeaks(hist);
% Get 2nd peak by sorting in descending order and choosing second index
peaks_sorted = sort(peaks,'descend');
second_peak = peaks_sorted(2);
%Find index of 2nd max
second_peak_index = find(counts==second_peak);
second_peak_index = max(second_peak_index);
% If multiple instances of intensity of second_peak exist, we want the
% highest index. There is probably a better way to do this.
%Determine intensity value of second peak
second_peak_intensity = binlocs(second_peak_index);
%Choose threshold value based on second peak
thresh_value = second_peak_intensity + 0.01;
%Create image segmentation based on dynamic threshold value
BW = MZ > thresh_value;
seg = MZ;
seg(~BW) = 0;



