如何在XY提取数据显然ImageJ读吗?

12 vu (au课程最后的30天时间)
塞布丽娜Lounis
塞布丽娜Lounis le Juil 2021
响应apportee: 焉耆刘 勒2021年9月27日
你好,
我需要帮助来提取(x, y)坐标1级。
这是程序是使用:
% %测试一个roi
我= imread (“部门1. png”);
图(1)
持有
I2 = imcrop(我);
我= im2gray (I2);
图(2)
[C, h] = imcontour (IM, 1);
% %提取数据
[contourTable, contourArray] = getContourLineCoordinates (C);
图(3)
持有
levelIdx = contourTable。水平= = h.LevelList (1);
情节(contourTable.X (levelIdx) contourTable.Y (levelIdx),“r”。,“MarkerSize”,1)
xdata = contourTable (: 3);
ydata = contourTable (: 4);
ct = [xdata, ydata];
writetable (ct,“Testtable.csv”)
getContourLineCoordinates (C)是一个函数在Matlab论坛上我发现。
我把所有的文件。
Sector1。pngis my original image that i want the (x,y) coordinates. I crop the image to have only the part of the heart, because i have a kind of shift when I divided my image in 12 equal part. Anyway, my goal now is to have a csv file with 2 columns : the first one for the x coordinate and the second one for the y. In fact, this file will be used in ImageJ (see attached TestImageJ.png). The issue is that, i think i have a problem of levels or too much points because the TestImageJ.png doesn't give me a clear contour of my original image, even if in Matlab when i plot (x,y) it seems to be enough clear.
谁能帮助我有更好的图像imageJ吗?
1 commentaire
图像分析
图像分析 le Juil 2021
你sector2图像没有任何轮廓。这是一个二进制图像。它只有轮廓/周长,而不是轮廓。你想写的(x, y)坐标集合到一个或多个的周长csv文件吗?

Connectez-vous倒评论者。

答案(1)

焉耆刘
焉耆刘 勒2021年9月27日
先生,可以使用如下代码参考
clc
关闭所有
清晰的所有
% %测试一个roi
我= imread (“https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/670963/Sector%201.png”);
图(1);imshow(我,[]);
持有
矩形= (235220、1290、1105);
(I2,矩形)= imcrop(我,矩形);
我= im2gray (I2);
图(2)
[C, h] = imcontour (IM, 1);
% %提取数据
如果ishandle (C)
C = C.ContourMatrix;
结束
%建立while循环
cmSize =大小(C, 2);% ContourMatrix中的列数
cmWindow = (0,0);%(开始、结束)指数移动窗口
contourArray = {};%存储每个轮廓线的(x, y)坐标
%提取每个轮廓线的坐标
cmWindow (2) < cmSize
cmWindow (1) = cmWindow (2) + 1;
cmWindow (2) = cmWindow (2) + C (2, cmWindow (1) + 1;
contourArray结束(+ 1)= {C (:, cmWindow (1): cmWindow (2))”。};% #好< AGROW >
结束
%不同级别、计算和坐标。
水平= cellfun (@ (c) c (1, 1), contourArray)。”;
numCoord = cellfun (@ c (c) (1、2), contourArray)。”;
contourArray = cellfun (@ (c) c(2:最终,:),contourArray,“UniformOutput”、假);
%按级别排序(以防Matlab不)
[~,sortIdx] =(高度);
%创建一个表与各级综合坐标和分组变量
levelsRep = cell2mat (arrayfun (@ (v、n) repmat (v, n, 1),水平(sortIdx) numCoord (sortIdx),
“UniformOutput”、假));
组= cell2mat (arrayfun (@ (v, n) repmat (v, n, 1),(1:元素个数(水平)。numCoord,
“UniformOutput”、假));
contourTable = array2table ([levelsRep、组vertcat (contourArray {sortIdx})),
“VariableNames”,{“水平”,“集团”,“X”,“Y”});
图(3)
持有
levelIdx = contourTable。水平= = h.LevelList (1);
情节(contourTable.X (levelIdx) contourTable.Y (levelIdx),“r”。,“MarkerSize”,1)
轴([1大小(IM, 2) 1大小(IM, 1)));
vdata = table2array (contourTable (:, 2));
xdata = contourTable (: 3);
ydata = contourTable (: 4);
ct = [xdata, ydata];
% writetable (ct, Testtable.csv)
图(4);imshow(我,[]);
持有
xt = table2array (xdata) +矩形(1);
欧美= table2array (ydata) +矩形(2);
i = 1:马克斯(vdata)
英蒂=找到(vdata = =我);
如果英蒂isempty ()
继续;
结束
情节(xt(英蒂),欧美(英蒂),“- - -”,“线宽”2);
结束
先生,现在你可以得到不同的轮廓的一部分,请检查和选择保存。

翻译的