필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by