Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

•Re: altsense.net image splitter

by merlyn (Sage)
on Mar 30, 2002 at 17:30 UTC ( #155446=note: print w/ replies, xml ) Need Help??


in reply to altsense.net image splitter

my $newImage01 = $img->crop( left=>0 , right=>218, to +p=>0 , bottom=>150 ) || die "$message: ($!)\n"; my $newImage02 = $img->crop( left=>218, right=>437, to +p=>0 , bottom=>150 ) || die "$message ($)): ($!)\n"; my $newImage03 = $img->crop( left=>437, right=>654, to +p=>0 , bottom=>150 ) || die "$message ($_): ($!)\n"; my $newImage04 = $img->crop( left=>0 , right=>218, to +p=>150, bottom=>300 ) || die "$message ($_): ($!)\n"; my $newImage05 = $img->crop( left=>218, right=>437, to +p=>150, bottom=>300 ) || die "$message ($_): ($!)\n"; my $newImage06 = $img->crop( left=>437, right=>654, to +p=>150, bottom=>300 ) || die "$message ($_): ($!)\n";
Unless I'm misreading Imager's docs, or it works in some bizarre ways, you're duplicating a thin line of pixels at each border. I think you want top 0, bottom 149 in one picture, and top 150, bottom 300 in the other. Similarly for left and right.

On a more general note, since you'll be now editing this portion of the code anyway {grin}, I'd get rid of that complex series of constants and use a computed loop anyway.

-- Randal L. Schwartz, Perl hacker


Comment on •Re: altsense.net image splitter
Download Code
Replies are listed 'Best First'.
Re: •Re: altsense.net image splitter
by djw (Vicar) on Apr 01, 2002 at 15:00 UTC
    Originally I thought as you did and only went to 149 in the first block, and same goes for the width. But when I took the images into photoshop, I noticed that they were no longer each 218x150. They were all missing one pixel depending on which row they were in (eg 217x150 or 218x149).

    If I do as you say then I lose pixel data from 149-150 on the grid and that isn't a good thing =) I think it helps if you think of the picture as a grid.

    I joined the picture back up (of my car - the sample image) and it doesn't seem to be duplicating any part of the image, but I could be wrong because its hard to tell. Maybe I'll join it again and switch my desktop resolution to 640x480 so I can see for sure.

    As for the chunk you mentioned above, yeah I should put that into a loop. I wrote the imager part seperate from the rest of the program and added it later - the code you posted was a quick test of Imager. I'll do that right away - I plan on making this a bit more flexible so you can adjust the croping etc.

    djw
      Originally I thought as you did and only went to 149 in the first block, and same goes for the width. But when I took the images into photoshop, I noticed that they were no longer each 218x150. They were all missing one pixel depending on which row they were in (eg 217x150 or 218x149).
      Sounds like a bug in either Imager or its docs. {grin}

      -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://155446]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2015-07-29 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (268 votes), past polls