How to detect a particular contour in a matlab plot?
조회 수: 4 (최근 30일)
이전 댓글 표시
I'm trying to extract a particular outline from a matlab pcolor plot (generated from a Matrix named 'M' which is uploaded here as well) as shown in this image. Original Plot
However I would like to extract the contour only, as shown here. (The yellow color line is the one which I would like to extract and is highlighted here for illustration purpose) Required Plot
But I'm getting the result as the following. ( I don't require any other bits/clutter apart from the curve) Obtained Plot
[~, threshold] = edge(M, 'sobel');
fudgeFactor = 0.6;
BWs = edge(M,'sobel', threshold * fudgeFactor);
se90 = strel('line',6,70);
se0 = strel('line',3,90);
BWsdil = imdilate(BWs, [se90 se0]);
BWnobord = imclearborder(BWsdil,18);
seD = strel('cube',3);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
pcolor(BWfinal);colormap(jet); shading interp;colorbar;
How to obtain only the contour as required? Do I have to use any edge detection filters or do I have to perform smoothing prior to applying any filters? Thanks for any pointers or suggestions to accomplish this.
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 6월 1일
If you already know the [x y] path, then you could consider improfile() . Or just call interp2 directly, similar to https://www.mathworks.com/matlabcentral/answers/342101-how-do-you-get-an-arbitrary-1-dimensional-line-scan-from-a-2d-matrix#comment_457886
댓글 수: 2
Walter Roberson
2017년 6월 9일
It sounds to me as if you need something like envelope detection
https://www.mathworks.com/help/signal/ref/envelope.html and https://www.mathworks.com/help/signal/ug/envelope-extraction-using-the-analytic-signal.html
However as you are working in 2D then perhaps what you should use is boundary() (requires R2014b or later; if you are using an earlier release look in the File Exchange for "active contours"
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!