Need to split image to make 2 separate images from one

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Need to split image to make 2 separate images from one

Post by aLabelMaker »

What's the best way to do this? the split would need to be done from a diagnol line, not vert or horiz based on how the image( two trees) is set up.

Thanks, Ya'll are awesome on here...so helpful.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to split image to make 2 separate images from one

Post by fmw42 »

Post a link to your image so that one can see what you need to do and explain where it needs to be split. Sound like you need to create a mask with two colors white and black and draw a triangle like polygon to fill one color and the rest be the other color. See -draw at http://www.imagemagick.org/Usage/draw/

also what is your IM version and platform
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

Here is the first image that needs to be split

http://davidfavor.com/web/images/archiv ... banana.jpg

Thanks..
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to split image to make 2 separate images from one

Post by fmw42 »

Please explain or draw lines on your photo to show how you want it split.
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

i would simply like to have each tree in a separate image to later be manipulated. The bottom black (ground) portion is not too important on how it is split. I just need to be able to work with each tree separately.

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to split image to make 2 separate images from one

Post by fmw42 »

run these 3 commands:


convert -size 2800x1949 xc:black -fill white \
-draw "polygon 1532,0 1532,756 1440,824 1440,1949 2800,1949 2800,0" \
-alpha off banana_mask.gif

convert banana.jpg banana_mask.gif -alpha off -compose copy_opacity -composite \
-compose over -background white -flatten banana_right.jpg

convert banana.jpg \( banana_mask.gif -negate \) -alpha off -compose copy_opacity -composite \
-compose over -background white -flatten banana_left.jpg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Need to split image to make 2 separate images from one

Post by anthony »

aLabelMaker wrote:i would simply like to have each tree in a separate image to later be manipulated. The bottom black (ground) portion is not too important on how it is split. I just need to be able to work with each tree separately.

Thanks
I would mask out the ground, as you say it is irrelevent. Perhaps make it a separate 'split'.
With the ground removed you now have two shapes, that can be segmented into two seperate images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

fmw42 wrote:run these 3 commands:


convert -size 2800x1949 xc:black -fill white \
-draw "polygon 1532,0 1532,756 1440,824 1440,1949 2800,1949 2800,0" \
-alpha off banana_mask.gif

convert banana.jpg banana_mask.gif -alpha off -compose copy_opacity -composite \
-compose over -background white -flatten banana_right.jpg

convert banana.jpg \( banana_mask.gif -negate \) -alpha off -compose copy_opacity -composite \
-compose over -background white -flatten banana_left.jpg

The first command went good and produced black/white polygon image.
The next 2 did not yield the right output with the trees. Both trees are present in both of the next 2 commands?
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

aLabelMaker wrote:
fmw42 wrote:run these 3 commands:


convert -size 2800x1949 xc:black -fill white \
-draw "polygon 1532,0 1532,756 1440,824 1440,1949 2800,1949 2800,0" \
-alpha off banana_mask.gif

convert banana.jpg banana_mask.gif -alpha off -compose copy_opacity -composite \
-compose over -background white -flatten banana_right.jpg

convert banana.jpg \( banana_mask.gif -negate \) -alpha off -compose copy_opacity -composite \
-compose over -background white -flatten banana_left.jpg

The first command went good and produced black/white polygon image.
The next 2 did not yield the right output with the trees. Both trees are present in both of the next 2 commands?
...I got what I wanted by changing the command to this...

convert banana.jpg \( banana_mask.gif -negate \) -alpha off -compose copy_opacity -composite \> -compose over -background none banana_leftp.png

I changed background to none, and took out the "-flatten" command and it worked.

Now planning to cut image so that only the tree's are shown in pic.

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to split image to make 2 separate images from one

Post by fmw42 »

convert banana.jpg \( banana_mask.gif -negate \) -alpha off -compose copy_opacity -composite \> -compose over -background none banana_leftp.png
This command does not make sense to me. Especially the \>.

Note that the \ at the end of the lines is unix and means command is continued to the next line.

What version and platform of IM are you using?
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

fmw42 wrote:
convert banana.jpg \( banana_mask.gif -negate \) -alpha off -compose copy_opacity -composite \> -compose over -background none banana_leftp.png
This command does not make sense to me. Especially the \>.

Note that the \ at the end of the lines is unix and means command is continued to the next line.
Oh, I didn't know that... This would be very helpful while i was finding code online as i have been adding the whole including the \>'s
No wonder I've been having so much trouble.
What version and platform of IM are you using?
Not sure how to check my version.

hmm, I believe I'm using the most updated version as I downloaded it only a few months ago with the help of a friend. Using on a mac book pro working through the bash shell..

It was strange because I did get an error message, but the image still appeared on mys desktop after I hit enter.

Lots of trial and "error".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to split image to make 2 separate images from one

Post by fmw42 »

You can check your version by:

convert -version


also

you can check what delegates you have installed by

convert -list configure

and look at the line starting with DELEGATES
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

fmw42 wrote:You can check your version by:

convert -version
I am using version 6.6.6-3

also

you can check what delegates you have installed by

convert -list configure

and look at the line starting with DELEGATES
DELEGATES bzlib fftw fontconfig freetype gs gvc jbig jpeg jng jp2 lcms lqr mpeg openexr png rsvg tiff x11 xml wmf zlib

That's what I got to work with :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to split image to make 2 separate images from one

Post by fmw42 »

what about your IM version, Qlevel and platform
aLabelMaker
Posts: 19
Joined: 2011-01-10T12:25:14-07:00
Authentication code: 8675308

Re: Need to split image to make 2 separate images from one

Post by aLabelMaker »

fmw42 wrote:what about your IM version, Qlevel and platform
Version: ImageMagick 6.6.6-3 2011-01-04 Q16

Not sure what you mean by platform. Are you talking about the processor?
Still learning computer language.
Post Reply