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!
