Info

此问题已关闭。 请重新打开它进行编辑或回答。

Matrix manipulation problem under MATLAB

2 次查看(过去 30 天)
dakhli mohamed
dakhli mohamed 2018-11-21
关闭: MATLAB Answer Bot 2021-8-20
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
Walter Roberson 2018-11-21
The last assignment to the window should be I not H.
Walter Roberson
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
Walter Roberson 2018-11-21
Nested for loops .
  7 个评论
Walter Roberson
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
dakhli mohamed 2018-11-22
attached an example,p.jpg
A=hyperImage123(3,C1(i,j),C2(i,j),C3(i,j)); % central pixel
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));

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by