【问题标题】:How to crop the sub-image using its centroid?如何使用其质心裁剪子图像?
【发布时间】:2020-01-11 13:04:23
【问题描述】:

要获得子图像,有imcrop 函数。但我想使用已经实现的centroid(x,y) 裁剪子图像。

Image = 512x512
Centroid = (x,y) = (178.92, 207.20)

此外,imcrop 函数不会将任何输入作为 Centroid。

B = imcrop(A, [col, row, width, height]; 

如何使用其质心裁剪子图像?

另外,根据使用(x, y)的中心估计的矩形的指定大小和位置,子图像被裁剪但输出不正确。

例如:

To calculate the input argument of `imcrop` function, we have:
Diam of Obj = 50 pixel. 
then its window = 50x50 pixel.
and so 57/2 = 28 to add and subtract of centroid.

Win_Obj = imcrop(RNod,[c(1)-28, c(2)-28, c(1)+28, c(2)+28]);

【问题讨论】:

  • 我不确定我是否理解:您想剪切图像的某些部分但您只知道 1 个位置?为什么你认为这是可能的?请详细说明....
  • @avermaet:我不知道这是否可能。是的,我只有一个位置,它是物体的质心。
  • @avermaet:是的,我使用 'regionprops' 获得了对象的信息,但它们不准确(对象是肿瘤)
  • 好的,我没有处理肿瘤图像的经验,但你不能在已知对象的角/边缘上添加一些百分比吗? (扩展裁剪区域)
  • 试试imcrop(img, [c(1)-28 c(2)-28 2*28 2*28])

标签: matlab crop centroid


【解决方案1】:

根据您的帖子以及docs,函数imcrop() 使用矩形作为[x_min y_min width height] 形式的第二个参数,因此您只需将imcrop 的调用更改为以下形式:

% c is the known centroid position
Win_Obj = imcrop(RNod, [c(1)-28 c(2)-28 2*28 2*28]);

这应该会给你一个子图像,你的对象在中心。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-07
    • 1970-01-01
    • 2014-12-21
    • 2014-05-26
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多