Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Image Analyst
Image Analyst am 28 Nov. 2021
Bearbeitet: Image Analyst am 28 Nov. 2021
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 Kommentare
Aaron Devanathan
Aaron Devanathan am 29 Nov. 2021
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 am 29 Nov. 2021
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by