How to convert 2D data to logical 3D array?
조회 수: 11 (최근 30일)
이전 댓글 표시
Hello everyone!
I have cancer cell data collected from Atomic Force Microscopy (bascially it's a scanning technique that allow to measure height in 3 dimension), where it gives me 512x512 pixels. For each pixel, there is a value correlated to the height on the cell. So I have 262144 different values as expected.
How can I convert it to 512x512x512 in 3D with the height being filled with number 1. (1 for filled space and 0 for blank space). So that at the end, my array is a logical array with only 0 and 1
Thank you so much
댓글 수: 0
채택된 답변
Walter Roberson
2021년 3월 17일
편집: Walter Roberson
2021년 3월 17일
idx = floor(double(Force) ./ maxForceReading * 511) + 1;
Force3d = reshape(1:512,1,1,[]) == idx;
untested.
댓글 수: 3
Walter Roberson
2021년 3월 17일
minForce = SEE DISCUSSION
maxForce = SEE DISCUSSION
maxScaledZ = 512;
dataAFM = double(test_1);
dataAFM(512*512+1:end) = []; %get rid of any extra beyond 512 x 512
dataAFM(end+1:512*512) = minForce; %pad in case of short data
dataAFM = round(dataAFM - minForce);
rgbimg = reshape(dataAFM, 512, 512).'; %vector elements are to go ACROSS first
ForceRange = maxForce - minForce;
idx = floor(rgbimg ./ ForceRange * (maxScaledZ-1)) + 1;
Force3d = reshape(1:maxScaledZ, 1, 1[]) == idx;
Now, in the above, minForce should not be min(dataAFM): it should instead be the smallest value that can be returned by the AFM. Likewise, maxForce should not be max() of the data: it should instead be the largest value that can be returned by the AFM.
The point is that when you are building your 3D shape, you want it to reflect some kind of absolute size, not some kind of relative size. If one experiment is a square with a round disk in the center that is a certain height, and another experiment is a square with a round disk in the center that is twice the height of the first experiment, you probably do not want the two to give the same output: you probably want an output for the second one which is about twice the Z height as the first.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
