フィルターのクリア

How to find the coordinates of edge from a figure and plot it on a separate/second figure?

1 回表示 (過去 30 日間)
Hello,
I am trying to find out the coordinates of the edge from this figure but it doesn't work for me. These are actually 35 bins in the image. I don't want any ellipse or rectangle around it. I want a proper boundary around these bins because I want to display that boundary in another figure. Here's the image;
I have tried this;
I = imread('myimage.jpg'); %2598x3071x3 uint8
II = rgb2gray(I);
edgeimage = edge(II, 'Canny');
[x y] = find(edgeimage);
Any help would be appreciated.

採用された回答

Walter Roberson
Walter Roberson 2023 年 11 月 26 日
I = imread('myimage.jpg'); %2598x3071x3 uint8
is_occupied = any(I ~= 255,3);
B = bwboundaries(is_occupied); %https://www.mathworks.com/help/images/ref/bwboundaries.html#bu1wval-1-B
However... you are using a jpg. It is almost guaranteed that jpg will give you the wrong results for this purpose. jpg is trash on sharp boundaries. Do not use jpg for any scientific measurement -- not unless the measurement you are doing is of exactly how trash jpg is for scientific use.
  2 件のコメント
Zhou Ci
Zhou Ci 2023 年 11 月 26 日
So, should I save my figure as png? Or which format is best to save such kind of figure?
Walter Roberson
Walter Roberson 2023 年 11 月 26 日
png would definitely be better than jpg .
However... if you have the data available to save into an image file, then why not work directly with the data instead of with the image of the data ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by