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.

 채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 12일

0 개 추천

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

Janice
Janice 2017년 5월 13일
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 2017년 5월 13일
편집: Image Analyst 2017년 5월 13일
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 2017년 5월 13일
Here Counts should be the horizontal projection, which is different from the original image YourSignal

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2017년 5월 12일

댓글:

2017년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by