フィルターのクリア

Creating a new array that contains number of overlap of non-zero values

2 ビュー (過去 30 日間)
Aaron Devanathan
Aaron Devanathan 2021 年 11 月 28 日
コメント済み: Image Analyst 2021 年 11 月 29 日
I have 4 equally sized arrays (under ARV.HEMEsubt_otsu), and the 'ARV' structure is attached with this question. I'm trying to create an array of equal size (105 x 107 double) that shows the total of the other arrays have non-zero values (i.e. 0, 1, 2, 3, or all 4). So for instance, at the row 75, column 57 cell location, only mz316 has a non-zero value so the new array would have a 1 in that cell in the new array.
I surmise a for loop that goes through the entire array and then assessing the others' cell values, but does anyone have any thoughts?
Happy to provide additional clarification as needed. Thanks!

採用された回答

Image Analyst
Image Analyst 2021 年 11 月 28 日
編集済み: Image Analyst 2021 年 11 月 28 日
Zeros add to zero, so why don't just add up those 4 arrays:
s=load('Arrays_11282021.mat')
s1 = s.ARV.HEMEsubt_otsu
m = s1.mz248 + ...
s1.mz288 + ...
s1.mz316 + ...
s1.mz445
imshow(m, [], 'InitialMagnification', 1600);
axis('on', 'image')
If you don't want the values themselves added, but just add 1 regardless ofthe value in there, just threshold at zero before adding:
s=load('Arrays_11282021.mat')
s1 = s.ARV.HEMEsubt_otsu
m = s1.mz248 > 0 + ...
s1.mz288 > 0 + ...
s1.mz316 > 0 + ...
s1.mz445 > 0
imshow(m, [], 'InitialMagnification', 1600);
axis('on', 'image')
  2 件のコメント
Aaron Devanathan
Aaron Devanathan 2021 年 11 月 29 日
Thanks @Image Analyst! I'll accept the answer. I'm curious: is there a way to display the image so that each number greater than 0 is its own color in the final array 'm'? Sorry if that's beyond the scope fo the question.
Image Analyst
Image Analyst 2021 年 11 月 29 日
Try this:
s = load('Arrays_11282021.mat')
s1 = s.ARV.HEMEsubt_otsu
m = uint8(s1.mz248 > 0) + ...
uint8(s1.mz288 > 0) + ...
uint8(s1.mz316 > 0) + ...
uint8(s1.mz445 > 0);
imshow(m, [], 'InitialMagnification', 1600);
axis('on', 'image')
impixelinfo; % Show (x,y) and value
colormap(lines(5))
colorbar

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by