Medri has asked for the wisdom of the Perl Monks concerning the following question:

I have written a script using GD::Image that produces a number of small grayscale images (32x32) to use in simple edge detection in a machine learning course. My problem is with the 'ground truth' images. The edges are marked with one single line of pixels, each image rotated in 8 different angles. For some images, the rotated ones are printed with just one pixel in each row, which is how I want it. On others, the line are made of pairs of 2 pixels in each row, making the line double size. Do anyone know why this is, and perhaps how I can fix it?

Examples of the images:

http://home.halden.net/piazava/perlmonks/ramp_4_gt.png

http://home.halden.net/piazava/perlmonks/ramp_4_gt_45.png

http://home.halden.net/piazava/perlmonks/ridge_4_gt.png

http://home.halden.net/piazava/perlmonks/ridge_4_gt_45.png

http://home.halden.net/piazava/perlmonks/roof_0_gt.png

http://home.halden.net/piazava/perlmonks/roof_0_gt_45.png

Thanks for your attention :)
  • Comment on Why does GD draw thicker lines on rotate?

Replies are listed 'Best First'.
Re: Why does GD draw thicker lines on rotate?
by zentara (Cardinal) on Feb 14, 2014 at 13:07 UTC
      Thank you for your reply, it was the same as my superviser suggested :) I have no idea how to get rid of it, yet. Here is the code for the rotate. To get the 'step edge' images correct, I have to rotate a larger image and then crop it to the right size.
      sub rotate { my ($img, $path) = @_; my @degrees = qw(45 90 135 180 225 270 315); my $cropped_orig = crop_image($img); my %images = (0 => $cropped_orig); foreach (@degrees) { my $image = GD::Image->new(CANVAS, CANVAS); $image->copyRotated($img, 32, 32, 1, 1, 64, 64, $_); $image = crop_image($image); $images{$_} = $image; } return \%images; }
        Did you ever solve this? I too have the same issue... Not sure what you mean re. rotating a larger image and then cropping.