如何在matlab中提取感兴趣区域内的对象

发布于 2024-12-10 06:41:17 字数 348 浏览 0 评论 0原文

我有兴趣提取该区域内的对象。

例如,

图 1 显示了我的激光轮廓的强度轮廓。根据激光强度,我将轮廓分为 2 个感兴趣区域(ROI1 和 ROI2)。

图 2 显示了我的阳性反应实验结果与激光强度分布的重叠。阳性响应数据文件由 x 和 y 坐标组成。正如您所看到的,结果分散在激光轮廓图像上。

这就是我想要做的,我想提取 ROI2 内的点并丢弃所有其余的,如图 3 所示。我该怎么做呢?具体来说,如何在matlab中定义不规则形状的ROI2并提取阳性反应数据的坐标。 感谢您的帮助。

在此处输入图像描述

I am interested in extracting the objects inside the region.

For example,

Fig1 showed the intensity profile of my laser profile. According to the laser intensity, I divide the profile into 2 region of interest (ROI1 and ROI2).

Fig2 showed the overlap of my exp result of positive responses and the laser intensity profile. The positive response data file is composed of x and y coordinates. As you can see the results are scattered over the laser profile image.

Here is what I want to do, I want to extract the spots within the ROI2 and discard all the rest as shown in Fig3. How can I do it? Specifically, how can I define a irregular shape ROI2 in matlab and extract the coordinates of positive response data.
Thanks for the help.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

国粹 2024-12-17 06:41:17

正如 eykanal 所说,您可以使用 impoly 函数来创建任何您想要的图像投资回报率。提取坐标的通用解决方案是创建所需的 ROI,并使用 find< /a> 提取坐标并进行一些设置操作以删除不需要的点。像这样:

imshow(image)
h         = impoly() ;      %# draw ROI1
ROI1      = createMask(h);  %# create binary mask of ROI1
h2        = impoly();       %# draw dummy_ROI consisting of ROI1+ROI2
dummy_ROI = createMask(h2); %# create binary mask
ROI2      = dummy_ROI-ROI1; %# create ROI2

p      = find(ROI2);        %# find all coordinates of ROI2
points = intersect(ind,p);  %# find all points with linear index ind that are
                            %# part of ROI2

As eykanal says, you can use the impoly function to create any sort of ROI you want in your image. A general solution for extracting coordiantes is to create the ROI you want, and the use find to extract the coordinates and some set operation to remove unwanted points. Like this:

imshow(image)
h         = impoly() ;      %# draw ROI1
ROI1      = createMask(h);  %# create binary mask of ROI1
h2        = impoly();       %# draw dummy_ROI consisting of ROI1+ROI2
dummy_ROI = createMask(h2); %# create binary mask
ROI2      = dummy_ROI-ROI1; %# create ROI2

p      = find(ROI2);        %# find all coordinates of ROI2
points = intersect(ind,p);  %# find all points with linear index ind that are
                            %# part of ROI2
神回复 2024-12-17 06:41:17

我认为这个问题比你想象的更容易,只要你总是沿着(看起来的)轮廓线分割图像。您想要选择值大于等高线 1 且小于等高线 2 的所有点。我不确定您如何指定等高线,但选择命令应该简单为:

#% let laserData be the image data (it looks like it should
#% be 512x256, so I'll assume that)

highBound = mean(contour1points);
lowBound  = mean(contour2points);

selectedData = laserData(laserData > lowBound & laserData < highBound);

如果,如图所示,您简单地根据值设置轮廓,然后可以将 mean(contour1points) 替换为用户定义的值,使用该函数获取光标下像素的值,这是我不可能发生的现在回想起来。如果要定义多边形,请查看 impoly函数

I think this problem is easier than you think, provided you always segment the image along (what appear to be) contour lines. You want to select all points which have a value greater than contour line 1 and less than contour line 2. I'm not sure how you specified the contour lines, but the selection command should simply be:

#% let laserData be the image data (it looks like it should
#% be 512x256, so I'll assume that)

highBound = mean(contour1points);
lowBound  = mean(contour2points);

selectedData = laserData(laserData > lowBound & laserData < highBound);

If, as it appears, you're simply setting contours based on value, then the mean(contour1points) could be replaced by a user-defined value, using the function to get the value of the pixel under the cursor which I can't happen to recall right now. If you want to define a polygon, check out the impoly function.

写给空气的情书 2024-12-17 06:41:17

我不知道您对 ROI 使用什么表示形式,但我建议一些方法:

  1. 如果您的 ROI 是椭圆形并且您知道它的方程,只需将其应用于结果坐标即可。使用符号来确定它是否在内部

  2. 如果您的 ROI 是某种多边形,您可以使用函数inpolygon

  3. 您可以将 ROI 渲染为黑白图像并轻松测试命中/未命中。

请提供有关 ROI 表示的更多详细信息。

I don't know what representation you use for your ROIs, but I would suggest some methods:

  1. If your ROI is an ellipse and you know its equation just apply it to the results coordinates. Use the sign to decide if whether it is inside or not

  2. If your ROI is a polygon of some kind you can use the function inpolygon

  3. You could render the ROIs to black and white images and easily test hit/miss.

Please provide more details regarding the ROI representation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文