Matrix manipulation problem under MATLAB
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hello
I have a treatment done on a single pixel I want to redo it on the whole image of tail 95 * 95
load('end3.mat')
d=size(A);
[carte] =hyperConvert3d(A,sqrt(d(2)), sqrt(d(2)),d(1));
P1=carte(:,:,1);
P2=carte(:,:,2);
P3=carte(:,:,3);
C1=round(P1*9);
C2=round(P2*9);
C3=round(P3*9);
i = input('Donner le numero de ligne');
j = input('Donner le numero de colone');
A=hyperImage123(3,C1(i,j),C2(i,j),C3(i,j));
B=hyperImage123(3,C1(i-1,j-1),C2(i-1,j-1),C3(i-1,j-1));
C=hyperImage123(3,C1(i-1,j),C2(i-1,j),C3(i-1,j));
D=hyperImage123(3,C1(i-1,j+1),C2(i-1,j+1),C3(i-1,j+1));
E=hyperImage123(3,C1(i,j-1),C2(i,j-1),C3(i,j-1));
F=hyperImage123(3,C1(i,j+1),C2(i,j+1),C3(i,j+1));
G=hyperImage123(3,C1(i+1,j-1),C2(i+1,j-1),C3(i+1,j-1));
H=hyperImage123(3,C1(i+1,j),C2(i+1,j),C3(i+1,j));
I=hyperImage123(3,C1(i+1,j+1),C2(i+1,j+1),C3(i+1,j+1));
Fenetre=zeros(9,9);
Fenetre(4:6,4:6)=A;
Fenetre(1:3,1:3)=B;
Fenetre(1:3,4:6)=C;
Fenetre(1:3,7:9)=D;
Fenetre(4:6,1:3)=E;
Fenetre(4:6,7:9)=F;
Fenetre(7:9,1:3)=G;
Fenetre(7:9,4:6)=H;
Fenetre(7:9,7:9)=H;
댓글 수: 5
Walter Roberson
2018년 11월 21일
what is hyperImage123?
dakhli mohamed
2018년 11월 21일
dakhli mohamed
2018년 11월 21일
Walter Roberson
2018년 11월 21일
The last assignment to the window should be I not H.
Walter Roberson
2018년 11월 21일
편집: Walter Roberson
2018년 11월 21일
note
Fenetre = [B, C, D;
E, A, F;
G, H, I]
No need for the subscripted assignments .
답변 (1개)
Walter Roberson
2018년 11월 21일
0 개 추천
Nested for loops .
댓글 수: 7
dakhli mohamed
2018년 11월 21일
Walter Roberson
2018년 11월 21일
load('end3.mat')
d=size(A);
[carte] =hyperConvert3d(A,sqrt(d(2)), sqrt(d(2)),d(1));
P1=carte(:,:,1);
P2=carte(:,:,2);
P3=carte(:,:,3);
C1=round(P1*9);
C2=round(P2*9);
C3=round(P3*9);
nr = size(C1,1);
nc = size(C1,2);
Fenetre = cell(nr-2,nc-2);
for i = 2:nr-1
for j = 2:nc-1
A=hyperImage123(3,C1(i,j),C2(i,j),C3(i,j));
B=hyperImage123(3,C1(i-1,j-1),C2(i-1,j-1),C3(i-1,j-1));
C=hyperImage123(3,C1(i-1,j),C2(i-1,j),C3(i-1,j));
D=hyperImage123(3,C1(i-1,j+1),C2(i-1,j+1),C3(i-1,j+1));
E=hyperImage123(3,C1(i,j-1),C2(i,j-1),C3(i,j-1));
F=hyperImage123(3,C1(i,j+1),C2(i,j+1),C3(i,j+1));
G=hyperImage123(3,C1(i+1,j-1),C2(i+1,j-1),C3(i+1,j-1));
H=hyperImage123(3,C1(i+1,j),C2(i+1,j),C3(i+1,j));
I=hyperImage123(3,C1(i+1,j+1),C2(i+1,j+1),C3(i+1,j+1));
Fenetre{i-1,j-1} = [B, C, D;
E, A, F;
G, H, I]
end
end
Fenetre = cell2mat(Fenetre);
The result will not be 285 by 285. You are building 9 x 9 windows, and 285 is not divisible by 9.
dakhli mohamed
2018년 11월 22일
편집: dakhli mohamed
2018년 11월 22일
Walter Roberson
2018년 11월 22일
Your Fenetre code clearly takes a single pixel and converts it to 9 x 9. If it is the applicable code then your final result size would have to be divisible by 9. If it is not the applicable code then it is difficult to assist you as we do not know what (if any) part of it is relevant.
dakhli mohamed
2018년 11월 22일
Walter Roberson
2018년 11월 22일
편집: Walter Roberson
2018년 11월 22일
"my code takes a single pixel and converts it to 3 x 3"
No, it does not. It takes a single pixel and converts it to 9 x 9.
Look at your code: you input a scalar i and scalar j from the user, and you create
Fenetre=zeros(9,9);
from it, which is clearly 9 x 9.
dakhli mohamed
2018년 11월 22일
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
