How to find all the submatrix locations of a given matrix? But the same cannot be in the image?

I want to save all submatrix locations from a given matrix ...

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 

allows you to find the location of the submatrix:

kkk =

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

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

I get the correct values ​​in the i and j matrix.

But if this "zzz" is replaced with some dicom image, and if "kkk" is a small part of this image, in this situation I do not get the desired values ​​of me and j ??? Does anyone help me?

0
source share
1 answer

you must change the row you wrote to fit your matrix sizes. for example, if DICOM images are 3D matrices, then:

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

or

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

may answer your problem.

If these are 4D arrays, you need to act accordingly ...

+1
source

Source: https://habr.com/ru/post/1482725/


All Articles