Permalink
Browse files

Externalized edge computation to removed duplication.

  • Loading branch information...
1 parent 79616a4 commit 1d901662337cca050cad2b7e393c8da87aedd429 @lailsonbm committed Oct 9, 2010
Showing with 16 additions and 29 deletions.
  1. +1 −1 .gitignore
  2. +11 −0 helpers/compute_edge.m
  3. +1 −7 helpers/load_images_and_edges.m
  4. +1 −7 utils/dump_reconstructions.m
  5. +1 −7 utils/scan_image.m
  6. +1 −7 utils/show_misclassified.m
View
2 .gitignore
@@ -4,4 +4,4 @@
*.jpeg
*.mat
data
-paper
+paper_*
View
11 helpers/compute_edge.m
@@ -0,0 +1,11 @@
+function edge = compute_edge(image, edge_method)
+
+if strcmpi(edge_method, 'sobel')
+ edge = sobel(image); % scale(sobel(image)) * 255;
+elseif strcmpi(edge_method, 'canny')
+ edge = canny(image);
+else
+ error('Invalid edge method.');
+end
+
+end
View
8 helpers/load_images_and_edges.m
@@ -5,13 +5,7 @@
edges = [];
for i = 1:size(paths,2)
image = double(imread(paths{i}));
- if strcmpi(edge_method, 'sobel')
- edge = sobel(image); % scale(sobel(image)) * 255;
- elseif strcmpi(edge_method, 'canny')
- edge = canny(image);
- else
- error('Invalid edge method.');
- end
+ edge = compute_edge(image, edge_method);
if isempty(images) || isempty(edges)
images = zeros(numel(image),size(paths,2));
View
8 utils/dump_reconstructions.m
@@ -14,13 +14,7 @@
disp(sprintf('Processing image %s...', srcpaths{i}));
image = double(imread(srcpaths{i}));
- if strcmpi(edge_method, 'sobel')
- edge = sobel(image); % scale(sobel(image)) * 255;
- elseif strcmpi(edge_method, 'canny')
- edge = canny(image);
- else
- error('Invalid edge method.');
- end
+ edge = compute_edge(image, edge_method);
imsize = size(image);
image = reshape(image,numel(image),1);
View
8 utils/scan_image.m
@@ -16,13 +16,7 @@
disp(sprintf('Scaling image to %.2f...', scale));
scaled_image = imresize(image, scale);
- if strcmpi(edge_method, 'sobel')
- scaled_edge = sobel(scaled_image); % scale(sobel(image)) * 255;
- elseif strcmpi(edge_method, 'canny')
- scaled_edge = canny(scaled_image);
- else
- error('Invalid edge method.');
- end
+ edge = compute_edge(image, edge_method);
% Scanning image
[windows,results] = slide_window(scaled_image, scaled_edge, total_errors);
View
8 utils/show_misclassified.m
@@ -13,13 +13,7 @@
for i = 1:size(paths,2)
image = double(imread(paths{i}));
- if strcmpi(edge_method, 'sobel')
- edge = sobel(image); % scale(sobel(image)) * 255;
- elseif strcmpi(edge_method, 'canny')
- edge = canny(image);
- else
- error('Invalid edge method.');
- end
+ edge = compute_edge(image, edge_method);
image = reshape(image,numel(image),1);
edge = reshape(edge,numel(edge),1);

0 comments on commit 1d90166

Please sign in to comment.