Your functions don't return any value, that means that you have to add a return argument to those functions (in case of the hough trafo, you'd like to return the accumulator array acc
) and as described in the manual (http://www.mathworks.de/de/help/matlab/ref/function.html), change the functions headers to:
function acc = HTPLine(inputimage)
and then also call it like this from the commandline (or from another script):
IMG = imread('some_image.jpg');
% e.g. convert to grayscale:
IMG = rgb2gray(IMG);
acc = HTPLine(IMG);
you then still need to find the maximum (or several maxima, depending on how many lines you'd like to fit) in the accumulator and display the fitted line (ellipse/circle) on your own via plot
in a figure...
EDIT: Looking at your code, I don't know what the variable r0
should be!? It will def. give you an errormsesage as it's not defined anywhere.
And why do you the if(inputimage(y,x)==0)
in your code? The pixel at the current point doesn't have to be black
in ordner to calculate the hough transformation for that single pixel (just think of a grey-image with a white line in it -> your code wouldn't do anything as the image wouldn't contain any black pixels). So that's what you need to rethink about.
If you want to, you could also use the built-in hough transformation of MATLAB: http://www.mathworks.de/de/help/images/ref/hough.html // http://www.mathworks.de/de/help/images/ref/houghpeaks.html