Page 1 of 1
How to split image to 2 parts?
Posted: 2009-06-01T02:14:08-07:00
by swistaczek
Heloo guys,
I have this picutre
I want split it to 2 parts like this:
oraz
Anyone can give me any hints how should I do it?
Thanks in advantage,
Ernest
Re: How to split image to 2 parts?
Posted: 2009-06-01T02:38:43-07:00
by Bonzo
Re: How to split image to 2 parts?
Posted: 2009-06-01T04:12:36-07:00
by swistaczek
The problem is that the image is diffrent size each time. I want split images by founding white space beetwen objects.
Re: How to split image to 2 parts?
Posted: 2009-06-01T04:53:25-07:00
by Bonzo
Did you look at the second link?
Re: How to split image to 2 parts?
Posted: 2009-06-01T17:57:44-07:00
by anthony
Okay if the images remain about the same size and you just want to divide them down the middel use
-crop 50%x100% +repage
A better method is being looked at.
If as you say you wnt to divide the image by looking for columns of a single color, I suggest you look at the script
http://www.imagemagick.org/Usage/scripts/divide_vert
The script is writte to divide the image based on rows of constant color, but can be easilly modified to do it by columns instead (or rotate the image 90 degrees
)
It will seperate the image into either 5 images end_white, first_part, middle_white, second_part, and end_white, BUT a flag can be given to ask it to just not output the areas of constant color, giving you just two images.
You could also modify the script (mail me your changes) to locate the middle section as well.
This is actually known as a segmentation issue. As such by converting your image into a mask of background and non-background areas you could also divide the image using the script
http://www.imagemagick.org/Usage/scripts/segment_image
When you have separated the mask areas, you can use them to mask the original image into separate parts.
This however should not be used directly as it will also separate the red 'spot' from the black area, unless the script is modified to only look for non-white pixels segments.
I would love to see both of these scripts converted into a various segmentation methods built into the IM library itself.
Re: How to split image to 2 parts?
Posted: 2009-06-02T01:43:34-07:00
by swistaczek
Hey,
I tried to use this script, but script returns me only 2 images of this:
containing 1px white color, and rest.
Re: How to split image to 2 parts?
Posted: 2009-06-02T05:59:36-07:00
by anthony
The script is an example which divides vertically!!!!
It will need to be modified to do horizontal division
Or rotate the images before and afterward.
As the script is pipeline compatible that is straightforward
convert input.png -rotate 90 miff:- | divide_vert -i - miff:- | convert - -rotate -90 +repage image_%d.png
The -i says to not output 'blank' image segments. In other words
However the image is JPEG. which means it does not have nice perfect colors, BUT it still worked producing two images!!!
For other JPEG images, we may need to improve the results by converting the image into a mask for separation, and then extracting the masked elements.
Re: How to split image to 2 parts?
Posted: 2009-06-03T04:14:09-07:00
by swistaczek
Thanks!
Code: Select all
convert input.jpeg -rotate 90 miff:- | ./divide_vert.sh -i - miff:- |convert - -rotate -90 +repage image_%d.jpeg
works great!
Re: How to split image to 2 parts?
Posted: 2012-01-24T15:57:32-07:00
by Geremia
Why not just do:
Code: Select all
convert -crop 50%x100% +repage input_image out%d_image
? It takes input_image and splits it vertically in half, forming out1_image and out2_image of the left and right halves. To split horizontally in half, just change 50%x100% to 100%x50%.
Re: How to split image to 2 parts?
Posted: 2012-01-24T16:29:32-07:00
by fmw42
If on Linux/Mac or Windows with cygwin, see my script multicrop at the link below. It is hard to know what you want since your links to your images are broken. Can you fix them, please.