In a loop, create an i x j matrix, find the average of each row, and find the minimum in which row.

조회 수: 3 (최근 30일)
Store matrix as i x j
store the difference between matrices m1 and m2 in m
After calculating the average value of each row of matrix m, which row has the minimum value is stored in k
m1 = [];
m2 = [];
% when img1 is up
for i = 1:5
for j = 1:h2_t1
st11H_t2 = st11H_t1(i:end,:,:);
st22H_t2 = st22H_t1(1:end-i,:,:);
p1 = impixel(st11H_t2, 1, j);
m1 = [m1, p1];
p2 = impixel(st22H_t2, w2_t1, j);
m2 = [m2, p2];
end
end
m1(~isfinite(m1))=0;
m2(~isfinite(m2))=0;
What should I do?
  댓글 수: 1
Image Analyst
Image Analyst 2022년 12월 26일
Please give a numerical example of your matrix and your desired output, like
m = magic(5)
m = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.

답변 (1개)

DGM
DGM 2022년 12월 26일
The answer is simple if you avoid the unnecessary loops.
inpict = uint8(randi([0 255],5,5)) % a 5x5 integer-class image
inpict = 5×5
111 109 89 67 118 129 139 165 13 148 207 32 78 47 61 51 127 171 203 147 205 176 60 254 205
rowmean = mean(inpict,2) % dim2 mean
rowmean = 5×1
98.8000 118.8000 85.0000 139.8000 180.0000
rowmin = min(inpict,[],2) % dim2 minima
rowmin = 5×1
67 13 32 51 60

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by