error due to function application

1 Ansicht (letzte 30 Tage)
Harry
Harry am 25 Jun. 2013
When I run the following code it gives the error:
Error: File: image_processing_project.m Line: 55 Column: 1
Function definitions are not permitted in this context.
I think there must be something wrong with the way I've placed the functions in the following code:
M = imread('C:\Users\bostock_h\Documents\Images\130510_162.jpg');
M = int16(M);
x = 975; %dimensions of the image
y = 1010;
sum=0;
steps = 12; %the number of steps taken for the average
lowlimit = 40; %minimum value to pass
highlimit = 200; %maximum value to pass
movel = 10; %amount of pixels moved to the left after check
prog = 0;
pixelnum = (x - movel - 1)*y; %Total number of pixels in the image
%Main loop begin
for j = 1:y
for i1 = movel + 1:x
c = checkright (i1,j);
if c ~= 0
b = 1;
else
b = -1;
end
if c == 0
c = checkleft (i1,j);
end
if c == -1
if b == 1
M(j,i1-movel) = 1;
end
end
if c == 1
if b == 1
M(j,i1-movel) = 250;
end
end
if c == 1
if b == -1
M(j,i1+movel) = 250;
end
end
if c == -1
if b == -1
M(j,i1+movel) = 1;
end
end
prog = prog + 1;
percent = (prog / pixelnum) * 100
end
end
imagesc(M)
colormap(gray)
function c = checkright(i1,j)
x1 = 1;
y1 = 0;
c = checkhorizontal(i1,j,x1);
end
function c = checkleft(i1,j)
x1 = -1;
y1 = 0;
c = checkhorizontal(i1,j);
function c = checkhorizontal(i1,j,x1)
for n = 0:steps
sum = M(j, i1 + n*x1) + sum;
end
avg = sum / steps;
if avg < lowlimit
c = -1*x1;
end
if avg > highlimit
c = 1*x1;
end
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Jun. 2013
The first line of your file named "image_processing_project.m" must be
function image_processing_project

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by