is it below code is right check with rules which I written in code for the attached image
1 次查看(过去 30 天)
显示 更早的评论
clc clear irgb=imread('file:///G:/STUDIES/M.Techproject/different%20edge%20detection%20result/fussy%20logic/experimental%20code/code/vehicle%20count%20with%20regulation/15.bmp'); is=imresize(irgb,[256 256]); st=tic; igray=0.2989*is(:,:,1)+0.5850*is(:,:,2)+0.1140*is(:,:,3); figure;image(igray,'CDataMapping','scaled');colormap('gray'); title('input image in grayscale') i=double(igray); classType=class(igray); scalingFactor=double(intmax(classType)); i=i/scalingFactor; Gx=[-1 1]; Gy=Gx; Ix=conv2(i,Gx,'same'); Iy=conv2(i,Gy,'same'); figure;image(Ix,'CDataMapping','scaled');colormap('gray'); title('Ix'); figure;image(Iy,'CDataMapping','scaled');colormap('gray'); title('Iy'); edgeFIS=newfis('edgeDetection'); edgeFIS=addvar(edgeFIS,'input','Ix',[-1 1]); edgeFIS=addvar(edgeFIS,'input','Iy',[-1 1]); sx=0.1; sy=0.1; edgeFIS=addmf(edgeFIS,'input',1,'zero','gaussmf',[sx 0]); edgeFIS=addmf(edgeFIS,'input',2,'zero','gaussmf',[sy 0]); edgeFIS=addvar(edgeFIS,'output','Iout',[0 1]); wa=0.1;wb=1; wc=1; ba=0;bb=0;bc=0.7; edgeFIS=addmf(edgeFIS,'output',1,'white','trimf',[wa wb wc]); edgeFIS=addmf(edgeFIS,'output',1,'black','trimf',[ba bb bc]); figure subplot(2,2,1);plotmf(edgeFIS,'input',1);title('Ix'); subplot(2,2,2);plotmf(edgeFIS,'input',2);title('Iy'); subplot(2,2,[3 4]);plotmf(edgeFIS,'output',1);title('Iout'); r1='if Ix is zero and Iy is zero then Iout is black'; r2='if Ix is not zero and Iy is not zero then Iout is white'; r3='if Ix is zero and Iy is not zero then Iout is black'; r4='if Ix is not zero and Iy is zero then Iout is black'; r=char(r1,r2,r3,r4); edgeFIS = parsrule(edgeFIS,r); showrule(edgeFIS) ieval=zeros(size(i)); for ii=1:size(i,1) ieval(ii,:)=evalfis([(Ix(ii,:));(Iy(ii,:));]',edgeFIS); end figure;image(i,'CDataMapping','scaled');colormap('gray'); title('original grayscale image') %is1=imresize(ieval,[128 128]); %figure(2);image(ieval,'CDataMapping','scaled');colormap('gray'); %title('edge detection using fuzzy logic') figure(2);imshow(ieval); et=toc(st); et
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fuzzy Logic in Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!