How to convert 2D data to logical 3D array?

10 ビュー (過去 30 日間)
Dang Nguyen
Dang Nguyen 2021 年 3 月 17 日
コメント済み: Walter Roberson 2021 年 3 月 17 日
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

採用された回答

Walter Roberson
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 件のコメント
Dang Nguyen
Dang Nguyen 2021 年 3 月 17 日
編集済み: Dang Nguyen 2021 年 3 月 17 日
It works now after your edit, thank for your help
Walter Roberson
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 ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by