如何找到给定矩阵的子矩阵的所有位置?但是不能在图像上找到相同的位置吗? [英] how to find all locations of a sub matrix of the given matrix?But the same cannot be on a image?

查看:83
本文介绍了如何找到给定矩阵的子矩阵的所有位置?但是不能在图像上找到相同的位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想存储给定矩阵中子矩阵的所有位置...

i want to store all locations of a sub matrix from given matrix...

例如: 给定矩阵: zzz =

For example: given matrix: zzz =

17    24     1     8    15
23     5     7    14    16
 4     6    13    20    22
10    12    19    21     3
11    18    25     2     9

让我想找到子矩阵的位置:

lets i want to find locations of submatrix:

kkk =

 5     7    14    16
 6    13    20    22
12    19    21     3
18    25     2     9

我尝试过 [i,j] = ind2sub(size(zzz),find(ismember(zzz,kkk)))

I tried [i,j] = ind2sub(size(zzz),find(ismember(zzz,kkk)))

我在i和j矩阵中得到了适当的值.

I get proper values in i and j matrix.

但是,如果此"zzz"被某个dicom图像替换,并且如果"kkk"只是该图像的一小部分,则在这种情况下,我将无法获得理想的i和j值???有人帮助我吗?

But if this 'zzz' is replaced by some dicom image and if 'kkk' is small part that image, in this situation i am not getting desirable i and j values??? somebody help me out???

推荐答案

您应根据矩阵尺寸修改编写的行.例如,如果DICOM图像是3D矩阵,则:

you should modify the line you wrote according to your matrix dimensions. for example, if DICOM images are 3D matrices, then:

  [i,j,k] = ind2sub(size(zzz),find(ismember(zzz,kkk)))

 [i,j] = ind2sub(size(zzz),find(ismember(zzz(:,:,k),kkk)))

可以回答您的问题.

如果它们是4D阵列,则需要采取相应措施...

If they are 4D arrays you need to act accordingly...

这篇关于如何找到给定矩阵的子矩阵的所有位置?但是不能在图像上找到相同的位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆