Finding Binary Values on 3D matrix

2 次查看(过去 30 天)
Articat
Articat 2019-11-13
I have a three dimmensional matrix, 2D dimensions of the matrix makes up the image ([894 896]) and the third dimension of the matrix is the images in time (100). Thus, the 3D matricie as a whole is: ([894 896 100]).
I have converted all of these images to binary images and traced the outline using "edge()" method. Thus, I have an image with a traced outline (just 0's and 1's). I now want to save these coordinates so I use the "find()" command. However, I don't know how to perform this on a 3D matrix? Basically for each of the 100 images I would like an outlined result with coordinate points. I have done this for one image so I know it works, I just want to do it automatically so that way I am not doing it 100 times manually.
How can I use "edge()" function on a 3D matrix? From the code below, "PLIFdata(:,:,i)" is just a 848x896x100 matrix.
PLIFadjust = zeros(848,896,100);
PLIF_binary = zeros(848,896,100);
PLIF_gaussfilt = zeros(848,896,100);
PLIF_sharpen = zeros(848, 896, 100);
PLIF_edge = zeros(848, 896, 100);
%% Tracing
n = 100;
for i = 1:n
PLIFadjust(:,:,i) = mat2gray(imadjust(PLIFdata(:,:,i)));
PLIF_binary(:,:,i) = mat2gray(PLIFadjust(:,:,i));
PLIF_gaussfilt(:,:,i) = imguidedfilter(imgaussfilt(PLIF_binary(:,:,i)));
PLIF_sharpen(:,:,i) = imsharpen(PLIF_gaussfilt(:,:,i), 'Radius', 1, 'Amount', 10);
PLIF_sharpen(PLIF_sharpen > .25) = 1;
PLIF_edge(:,:,i) = edge(PLIF_sharpen(:,:,i), 'Sobel');
[y, x, z] = find(PLIF_edge(:,:,i)); ------------------------------> What I am not sure how to compute?
end

回答(1 个)

Prabhan Purwar
Prabhan Purwar 2019-11-22
Following code illustrates the find() function upon 3D matrix
a(:,:,1) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
a(:,:,2) =
1 0 1 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
>> find(a)
ans =
26 (for a(1,1,2))
36 (for a(1,3,2))
50 (for a(5,5,2))
Although, it is recommended to do the processing upon 2D matrix (Image) extracted from 3D matrix data (To avoid complexity).
Refer to the following link for further information:

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by