How to caculate x,y coordinates in a contoured region

1 回表示 (過去 30 日間)
Muhammad
Muhammad 2013 年 9 月 6 日
Hello All
Hope yopu are all good. i have a question i used the code below. i contoured the region by imfreehand tool. i want to calculate the coordinates( x, y,z) in this region which i contourd. i can calculate the coordinates on the line which is made by imfreehand by ginput. but i need the coordinates which are in the contoured region.
% Display a file
I = imread('cat.jpg');
imshow(I);
zoom on; % use mouse button to zoom in or out
% Press Enter to get out of the zoom mode. % CurrentCharacter contains the most recent key which was pressed after opening % the figure, wait for the most recent key to become the return/enter key
waitfor(gcf,'CurrentCharacter',13) zoom reset zoom off imfreehand
% the figure, wait for the most recent key to become the return/enter key
imfreehand(gca,'closed',0) end
Any help is appreciated in advance.

採用された回答

Image Analyst
Image Analyst 2013 年 9 月 6 日
Explain why you think you need the (x,y) coordinates of all the pixels inside the hand drawn region, rather than just the boundary coordinates. I've never needed them and suspect you don't really need them either. I know how to get them, but I don't want to send you down an unproductive path for no reason.
  16 件のコメント
Image Analyst
Image Analyst 2013 年 9 月 16 日
Not sure what you want to do. I'm not sure what "will come on the excel sheet" means. Instead of "come on" do you mean "come from" or "go to"? Call xlsread() if you want to retrieve values from a workbook. Call xlswrite() if you want to send values to a workbook.
Muhammad
Muhammad 2013 年 9 月 16 日
編集済み: Muhammad 2013 年 9 月 16 日
when i applies the below code on a image like cat image then i can find [Y,X] coodinates on spread sheet with name of data that contains 2 arrays having Y and X values. X and Y seprately also available as a spread sheet in workspace. these values are the coordinates of each pixel inside the contoured region. but when i made interface then i cant find that spread shee on work space.
if true
I = imread('cat.jpg');
imshow(I);
% image;
zoom on; % use mouse button to zoom in or out
% Press Enter to get out of the zoom mode.
% CurrentCharacter contains the most recent key which was pressed after opening
% the figure, wait for the most recent key to become the return/enter key
waitfor(gcf,'CurrentCharacter',13)
zoom reset
zoom off
% imfreehand
% the figure, wait for the most recent key to become the return/enter key
h=imfreehand(gca,'closed',0);
pos = getPosition(h);
sz = size(I);
maskedImage = poly2mask(pos(:,1), pos(:,2), sz(1), sz(2));
[Y, X] = find(maskedImage ~= 0);
data=[Y,X];
end
Now i think you will better understand. thnaks in advance.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by