Finding Binary Values on 3D matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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:
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!