-3

my source code:

function void = find_edge()
path_io = 'io_find_edge\';
format = '.jpg';
list_img = ['Parent_006.jpg'; 'Parent_007.jpg'; 'Parent_008.jpg'; 'Parent_009.jpg'; 'Parent_010.jpg'];
list_filter = {'sobel', 'canny', 'prewitt', 'roberts', 'log'};

for index = 1:size(list_img)
    img_name = list_img(index, 1:10);
    img = rgb2gray(imread([path_io img_name format]));
    for filter = list_filter
        imwrite(edge(img, filter), [img_name '_' filter format], 'jpeg');
    end
end

error: Undefined function 'power' for input arguments of type 'cell'.

Error in edge (line 420) cutoff = (thresh).^2;

Error in find_edge (line 15) x = edge(img, filter);

thanks!

Arman
  • 367
  • 3
  • 12
  • 1
    You show us an error inside a function we don't know. Please post relevant code. `filter` is an in-built function, don't use it as a variable name! Maybe that already solves the problem. Where do you define it actually? – Robert Seifert Feb 13 '15 at 09:58

1 Answers1

0

Inside the inner for loop, filter will be a cell with only one entry containing the current filter name. Still it is a cell array, so the edge function returns an error. You will can access the content of filter, i.e. the string with the current filter name, by using filter{:}.

I think you also have an error in constructing the file name. I assume you want to use filter instead of list_filter to create the filename, right?

Thus:

imwrite(edge(img, filter{:}), [img_name '_' filter{:} format], 'jpeg');

PS: as @thewaywewalk remarked in a comment, filter is the name of a function. It is not advisable to use it as a variable name, as then the filter function won't work anymore. I suggest to rename it to e.g. current_filter.

hbaderts
  • 14,136
  • 4
  • 41
  • 48