MATLAB: Remove boundaries (histogram), other method

extractionhelphistogramimage processingImage Processing Toolboxpeak and valleyremove boundary

As seen in the image, this is the horizontal histogram projection of my image.The signal with peaks value around 1200 is the boundary. I wish to remove signal which its peak exceed more that 600 and left with the signal in the middle. How to wrote the code so that every different image that be process could remove the signal by remove the signal which has the peak more that 600?
or maybe to crop the signal at the valley?
Tq so much.

Best Answer

left_edge = find( Counts(1:end-1) >= 600 & Counts(2:end) < 600, 1, 'first');
right_edge = find( Counts(left_edge+1:end-1) < 600 & Counts(left_edge+2:end) >= 600, 1, 'first') + left_edge;
cropped_Signal = YourSignal(left_edge+1 : right_edge, :);