Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 17 additions and 13 deletions.
  1. +4 −1 code/detect_square/findsquare.m
  2. +13 −12 code/detect_square/runme.m
View
5 code/detect_square/findsquare.m
@@ -21,6 +21,8 @@
maxsquare = bb;
end
end
+cropped_img = imcrop(bw, maxsquare);
+%{
figure('visible', 'off'), imshow(bw, 'Border', 'tight');
hold on;
rectangle('position',maxsquare,'edgecolor','r','linewidth',2);
@@ -28,6 +30,7 @@
f = getframe(gca);
[X, map] = frame2im(f);
output_img = X;
-
+%}
+output_img = cropped_img;
end
View
25 code/detect_square/runme.m
@@ -17,12 +17,19 @@
filename = filenames(i).name;
% Check if filename is an image
- if (~isempty(strfind(filename, '.jpg')))
+ if (~isempty(strfind(filename, '.jpg')) || ~isempty(strfind(filename, '.png')))
- % Determine filenames
- basename = strrep(filename, '.jpg', '');
- input_filename = strcat('../../input/', basename, '.jpg');
- output_filename = strcat('../../output/square_', basename, '.jpg');
+ if (~isempty(strfind(filename, '.jpg')))
+ % Determine filenames
+ basename = strrep(filename, '.jpg', '');
+ input_filename = strcat('../../input/', basename, '.jpg');
+ output_filename = strcat('../../output/square_', basename, '.jpg');
+ elseif(~isempty(strfind(filename, '.png')))
+ basename = strrep(filename, '.png', '');
+ input_filename = strcat('../../input/', basename, '.png');
+ output_filename = strcat('../../output/square_', basename, '.png');
+ end
+
% Create output image, if it does not already exist
if (force_overwrite || ~exist(output_filename, 'file'))
@@ -40,15 +47,9 @@
% adaptive thresholding to convert to bw image
- bw = adaptivethreshold(input_image, 11, 0.03);
+ bw = adaptivethreshold(input_image, 15, 0.06);
output_image = findsquare(bw);
- % Compute gradients
-% [xgradient_image, ygradient_image] = computegradients ( input_image );
-
- % Combine Canny and Hough into final output
-% output_image = predictlines( canny_image, hough_transform, xgradient_image, ygradient_image, 1.0, 1.0, 2.0 );
-
% End timer
toc

No commit comments for this range

Something went wrong with that request. Please try again.