How to split image to 2 parts?
How to split image to 2 parts?
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
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?
If the sizes are the same use crop http://www.imagemagick.org/script/comma ... s.php#crop or check out this thread:
viewtopic.php?f=1&t=10377&p=32751&hilit ... age#p32751
viewtopic.php?f=1&t=10377&p=32751&hilit ... age#p32751
Re: How to split image to 2 parts?
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?
Did you look at the second link?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to split image to 2 parts?
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.
-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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to split image to 2 parts?
Hey,
I tried to use this script, but script returns me only 2 images of this:
containing 1px white color, and rest.
I tried to use this script, but script returns me only 2 images of this:
containing 1px white color, and rest.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to split image to 2 parts?
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to split image to 2 parts?
Thanks!
works great!
Code: Select all
convert input.jpeg -rotate 90 miff:- | ./divide_vert.sh -i - miff:- |convert - -rotate -90 +repage image_%d.jpeg
Re: How to split image to 2 parts?
Why not just do:? 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%.
Code: Select all
convert -crop 50%x100% +repage input_image out%d_image
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to split image to 2 parts?
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.