probabilistic neural network error
조회 수: 1 (최근 30일)
이전 댓글 표시
i have a cource code like this, and i have error, any body help me ... plisss :(
it's a part of gambar1.m
mm=10;
d=imread(filename)
r=d;
m=fspecial('unsharp');
x=imfilter(r,m);
data=x;
pathname = 'D:\Deniel Data\SKRIPSI\APLIKASI\Hish_Pass_Filter\';
% mkdir(pathName);
imwrite(data,[pathname, 'HPV','.jpg']);
[r,c]=size(x);
max=0;
min=0;
for j=2:r-1
for i=2:c-1
p=i-1;
q=i+1;
a=j-1;
b=j+1;
d1=abs(x(j,i)-x(j,p));
d2=x(j,i)-x(j,q);
e1=x(j,i)-x(a,i);
e2=x(j,i)-x(b,i);
f1=x(j,i)-x(a,p);
f2=x(j,i)-x(b,q);
g1=x(j,i)-x(a,q);
g2=x(j,i)-x(b,p);
if (d1 < 0)
d1=d1*(-1);
end
if (d2 < 0)
d2=d2*(-1);
end
if (e1 < 0)
e1=e1*(-1);
end
if (e2 < 0)
e2=e2*(-1);
end
if (f1 < 0)
f1=f1*(-1);
end
if (f2 < 0)
f2=f2*(-1);
end
if (g1 < 0)
g1=g1*(-1);
end
if (g2 < 0)
g2=g2*(-1);
end
if (d1 >= mm) && (d2 >= mm)
x(j,i)=255;
elseif (e1 >= mm) && (e2 >= mm)
x(j,i)=255;
elseif (f1 >= mm) && (f2 >= mm)
x(j,i)=255;
elseif (g1 >= mm) && (g2 >= mm)
x(j,i)=255;
else
x(j,i)=0;
end
end
end
e=x
data=e;
pathname = 'D:\Deniel Data\SKRIPSI\APLIKASI\Gambar_Canny\';
% mkdir(pathName);
imwrite(data,[pathname, 'Canny','.jpg']);
sakita=reshape(x,[10000 1]);
data=sakita;
pathname = 'D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\';
% mkdir(pathName);
imwrite(data,[pathname, 'sakita','.jpg']);
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%function KikyPNN()
%ini adalah contoh kode program membuat PNN menggunakan fungsi newpnn
%data yang akan di testing disimpan dalam matriks Testdata
%hasil testing akan disimpan dalam matriks Yc.
%bandingkan hasiltestdata dengan yang seharusnya
%gunakan perintah “help newpnn” pada Command Line untuk mempelajari menggunakan fungsi newpnn
%clear;
%for handles.aa=handles.1:1:handles.30
% handles.aa=[handles.aa:hanldes.aa]
%end
% DIR returns as a structure array. You will need to use () and . to get
% the file names.
A = gambar1(hObject, eventdata, handles);
aa=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakita.jpg');
B = gambar2(hObject, eventdata, handles);
bb=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakitb.jpg');
C = gambar3(hObject, eventdata, handles);
cc=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakitc.jpg');
D = gambar4(hObject, eventdata, handles);
dd=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakitd.jpg');
E = gambar5(hObject, eventdata, handles);
ee=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakite.jpg');
F = gambar6(hObject, eventdata, handles);
ff=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakitf.jpg');
G = gambar7(hObject, eventdata, handles);
gg=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakitg.jpg');
H = gambar8(hObject, eventdata, handles);
hh=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakith.jpg');
I = gambar9(hObject, eventdata, handles);
ii=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakiti.jpg');
J = gambar10(hObject, eventdata, handles);
jj=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakitj.jpg');
K = gambar11(hObject, eventdata, handles);
kk=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehata.jpg');
L = gambar12(hObject, eventdata, handles);
ll=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehatb.jpg');
M = gambar13(hObject, eventdata, handles);
mm=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehatc.jpg');
N = gambar14(hObject, eventdata, handles);
nn=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehatd.jpg');
O = gambar15(hObject, eventdata, handles);
oo=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehate.jpg');
P = gambar16(hObject, eventdata, handles);
pp=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehatf.jpg');
Q = gambar17(hObject, eventdata, handles);
qq=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehatg.jpg');
R = gambar18(hObject, eventdata, handles);
rr=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehath.jpg');
S = gambar19(hObject, eventdata, handles);
ss=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehati.jpg');
T = gambar20(hObject, eventdata, handles);
tt=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sehatj.jpg');
%Data(1:10000,1:3)=zeros;
%Data(1,1:10000)=sakita';
%Data1=sakita';
%Data(2,:)=sakitb;
%Data(3,:)=sehata;
%tic
%Dataasli=Data
%a=ones(1,10000);
%b=2*ones(1,10000);
%clear handles.aa;
%Dataasli = [gambar1 gambar2 gambar3] % terjadi pelupingan data
Dataasli = [aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt];
%Dataasli=[1 1 2]
Kelasdataasli = [1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2];
T = ind2vec(Kelasdataasli)
net = newpnn(Dataasli,T)
%mm=input('Input your threshold between 0 and 255 ');
testdata=[handles.f]
% bila test data sudah benar, ,maka hasil dari test data yang sesuai dengan
% data asli masuk otomatis kedalam data asli ututan +1
%testdata=[handles.g]
%testdata=Y=reshape(x,1)
Y = sim(net,testdata)
Yc = ind2vec(Y)
hasiltestdata=Yc
an the error is :
T =
(1,1) 1
(1,2) 1
(1,3) 1
(1,4) 1
(1,5) 1
(1,6) 1
(1,7) 1
(1,8) 1
(1,9) 1
(1,10) 1
(2,11) 1
(2,12) 1
(2,13) 1
(2,14) 1
(2,15) 1
(2,16) 1
(2,17) 1
(2,18) 1
(2,19) 1
(2,20) 1
Error using network/subsasgn>network_subsasgn (line 536)
net.IW{1,1} must be a 20-by-10000 matrix.
Error in network/subsasgn (line 13)
net = network_subsasgn(net,subscripts,v,netname);
Error in newpnn>create_network (line 122)
net.iw{1,1} = p';
Error in newpnn (line 66)
net = create_network(param);
Error in aplikasi>pushbutton2_Callback (line 301)
net = newpnn(Dataasli,T)
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in aplikasi (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)aplikasi('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
댓글 수: 0
답변 (1개)
Walter Roberson
2012년 6월 7일
JPEG images cannot be pseudocolor (2 dimensional) images, so each imread() you are doing is reading in a truecolor (3 dimensional) array. You horzcat() the 20 images together, which is going to still result in a 3 dimensional array. You pass that to newpnn() as the first argument. newpnn() is only documented as accepting 2D arrays for its first argument.
댓글 수: 13
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!