## matlab

سلام
نیاز فوری دارم بدونم برنامه زیر چیکار می کنه
ممنون
function im_out = imscan (net,im)

close all

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
% PARAMETERS
SCAN_FOLDER = &#039;imscan/&#039;;
UT_FOLDER = &#039;imscan/under-thresh/&#039;;
TEMPLATE1 = &#039;template1.png&#039;;
TEMPLATE2 = &#039;template2.png&#039;;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~

warning off;
delete ([UT_FOLDER,&#039;*.*&#039;]);
delete ([SCAN_FOLDER,&#039;*.*&#039;]);

[m n]=size(im);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
% First Section
C1 = mminmax(double(im));
Corr_1 = double(conv2 (C1,C2,&#039;same&#039;));
Corr_2 = double(conv2 (C1,C3,&#039;same&#039;));
Cell.state = int8(imregionalmax(Corr_1) | imregionalmax(Corr_2));
Cell.state(1:13,:)=-1;
Cell.state(end-13:end,:)=-1;
Cell.state(:,1:9)=-1;
Cell.state(:,end-9:end)=-1;
Cell.net = ones(m,n)*-1;
[LUTm LUTn]= find(Cell.state == 1);
imshow(im);
hold on
plot(LUTn,LUTm,&#039;.y&#039;);pause(0.01);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
% Second Section
xo = [-1,-1,-1, 0, 0,+1,+1,+1]; %offset
yo = [-1, 0,+1,-1,+1,-1, 0,+1]; %offset
while (1==1)
[y x] = find(Cell.state==1,1);
if isempty(y)
break;
end
imcut = im(y-13:y+13,x-9:x+8);
Cell.state(y,x) = -1;
Cell.net(y,x) = svmclassify(net,im2vec(imcut)&#039;);
if (Cell.net(y,x) == 1)
plot(x,y,&#039;.g&#039;);pause(0.01);
for k=1:8
nx = x + xo(k);
ny = y + yo(k);
if (Cell.state(ny,nx) ~= -1)
Cell.state(ny,nx) = 1;
end
end
else
plot(x,y,&#039;.r&#039;);pause(0.01);
end
end

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
% Third Section
hold off
figure;imshow (Cell.net,&#91;]);
xy_ = Cell.net &gt; 0;
xy_ = imregionalmax(xy_);
xy_ = imdilate (xy_,strel(&#039;disk&#039;,2,4));
[LabelMatrix,nLabel] = bwlabeln(xy_,4);
CentroidMatrix = regionprops(LabelMatrix,&#039;centroid&#039;);
xy_ = zeros(m,n);
for i = 1:nLabel
xy_(fix(CentroidMatrix(i).Centroid(2)),...
fix(CentroidMatrix(i).Centroid(1))) = 1;
end
xy_ = drawrec(xy_,[27 18]);
im_out (:,:,1) = im;
im_out (:,:,2) = im;
im_out (:,:,3) = im;
for i = 1:m
for j=1:n
if xy_(i,j)==1
im_out (i,j,1)=0;
im_out (i,j,2)=255;
im_out (i,j,3)=0;
end
end
end
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
function out = drawrec (in,w)

[m n]=size(in);
[LUTm LUTn]=find(in);
out = zeros (m,n);
for i =1:size(LUTm,1)
try
out (LUTm(i),LUTn(i))=0;
end
try
out (LUTm(i)-14:LUTm(i)+13,LUTn(i)-9)=1;
end
try
out (LUTm(i)-14:LUTm(i)+13,LUTn(i)+8)=1;
end
try
out (LUTm(i)-14,LUTn(i)-9:LUTn(i)+8)=1;
end
try
out (LUTm(i)+13,LUTn(i)-9:LUTn(i)+8)=1;
end
end
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
function output = mminmax(input)

max_ = max(max(input));
min_ = min(min(input));

output = ((input-min_)/(max_-min_) - 0.5) * 2;