Remove boundaries (histogram), other method?

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.

 Réponse acceptée

Walter Roberson
Walter Roberson le 12 Mai 2017
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, :);

3 commentaires

Janice
Janice le 13 Mai 2017
Tq so much for your answer, at first there was an error showing Counts as undefined variable, but somehow with some changes, it success. Just define the Counts as the "Your Signal" and you will be good to go.
Appreciate your help
Image Analyst
Image Analyst le 13 Mai 2017
Modifié(e) : Image Analyst le 13 Mai 2017
If you want to crop your image, and the "horizontal projection" is s sum or mean from top to bottom, then you should use your image variable instead of Counts, like maybe you called it grayImage or img or something instead of YourSignal. Using Counts will not crop the image, it will just crop the Counts projection vector. You could also use imcrop(), though indexing is probably easier.
croppedImage = grayImage(left_edge+1 : right_edge, :);
where left_edge and right_edge correspond to rows (lines) in the image.
Walter Roberson
Walter Roberson le 13 Mai 2017
Here Counts should be the horizontal projection, which is different from the original image YourSignal

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by