MATLAB: get index of minima in 3D array -


i have little question matlab.

i have 3d-array each 2d-layer picture. need "third" index (=the number of layer) of lowest value each pixel in array. @ end want have 2d array have index of these lowest values.

an example:

3d array these 2 2d-layers:

layer 1:

3-5-6 1-4-2 7-5-2 

layer 2:

1-8-2  4-6-1  9-2-5 

the result should following array:

2-1-2 1-1-2 1-2-1 

i hope can see want achieve, sorry bad english, cannot express problem in words...

thank help.

let a matrix can use

[b, i] = min(a, [], 3); 

where b minimum values , i contains indices. if not interested in minimum values can use

[~, i] = min(a, [], 3); 

for example

>> a(:,:,1) = [3 5 6; 1 4 2; 7 5 2]; >> a(:,:,2) = [1 8 2; 4 6 1; 9 2 5]; >> [b,i]=min(a, [], 3) b =      1     5     2      1     4     1      7     2     2 =      2     1     2      1     1     2      1     2     1 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -