Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Why does GD draw thicker lines on rotate?

by Medri (Initiate)
on Feb 14, 2014 at 12:48 UTC ( [id://1074954]=perlquestion: print w/replies, xml ) Need Help??

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 (Archbishop) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1074954]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found