probabilistic neural network error

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

Antworten (1)

Walter Roberson
Walter Roberson am 7 Jun. 2012

0 Stimmen

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 Kommentare

deniel munthe
deniel munthe am 8 Jun. 2012
would you want give me example with horzcat() , i really nead it.
deniel munthe
deniel munthe am 8 Jun. 2012
sir can you help me. oh, before fspacial, images have canges to grayscale before. im use imread, for inisialisation images before it
Walter Roberson
Walter Roberson am 8 Jun. 2012
The [ ] list operator is already horzcat(), except when it sees semi-colon
Your line
Dataasli = [aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt];
is already the same as
Dataasil = horzcat(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt];
However, since
aa=imread('D:\Deniel Data\SKRIPSI\APLIKASI\ReShape\sakita.jpg');
aa is going to be a 3D array, and the other variables are going to be 3D arrays (red, green, blue for each pixel), so when you horzcat() them together you get a 3D array as a result.
If you do not want a 3D array as a result, then you probably should not be using [ ] on 3D arrays.
deniel munthe
deniel munthe am 10 Jun. 2012
before i'm use imread, i have a process for images sakitaa before. n source code is
function [sakita]=gambar1(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=imread('D:\Deniel Data\SKRIPSI\APLIKASI\sel sakit\sakita.jpg');
b=a;
c=rgb2gray(b);
d=imresize(c,[100 100]);
data=d;
pathname = 'D:\Deniel Data\SKRIPSI\APLIKASI\Gambar_Grayscale\';
% mkdir(pathName);
imwrite(data,[pathname, 'grayscale','.jpg']);
mm=10;
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','.bmp']);
%sakita=reshape(data,[10000 1]);
Walter Roberson
Walter Roberson am 10 Jun. 2012
You write out a number of images, but you are not writing out the images that you imread() in pushbutton2_Callback
deniel munthe
deniel munthe am 10 Jun. 2012
so what i must to do for fix it, i'm very stack here.
deniel munthe
deniel munthe am 10 Jun. 2012
owh i'm sorry before,
it's the right code when i'm use for pushbutton-callback2.
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']);
%sakita=reshape(data,[10000 1]);
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']);
%sakita=reshape(data,[10000 1]);
i'm use .jpg not .bmp, but i'm always have an error
Walter Roberson
Walter Roberson am 10 Jun. 2012
Okay, to check: what does size(aa) show? And size(Dataasli) and size(T) ?
deniel munthe
deniel munthe am 10 Jun. 2012
aa is <10000x1 uint8> min 0 , max 255, Dataasli is <10000x20 uint8> min 0 max 255,
Kelasdataasli = [1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2];
T = ind2vec(Kelasdataasli)
T is <2x20 sparse double>
now, what i must to do ?
deniel munthe
deniel munthe am 11 Jun. 2012
are you have any idea ?
Walter Roberson
Walter Roberson am 11 Jun. 2012
I would suggest _experimenting_ as
newpnn(Dataasli .', T)
deniel munthe
deniel munthe am 11 Jun. 2012
have error with net=newpnn(Dataasli .', T)
Error using network/subsasgn>network_subsasgn (line 536)
net.IW{1,1} must be a 20-by-20 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 302)
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
Walter Roberson
Walter Roberson am 11 Jun. 2012
Sorry, I do not know. I do not have that toolbox to test with.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Jun. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by