How do I smooth out or delete pointy bits on the edge of an image
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
How do I smooth out or delete pointy bits on the edge of an image
Hello,
First time posting on here. Fairly new to the workings of ImageMagick so please go easy on me. Been struggling trying to solve this problem for ages.
Here's the problem...
I have lots of images with transparent white backgrounds that have a few jaggy pointy bits round the edges here and there and I would like to remove these annoying areas altogether by perhaps using geometry to pinpoint each exact location then converting the pixels to transparent white or deleting the pixels altogether.
How would I do this? Any ideas anyone?
First time posting on here. Fairly new to the workings of ImageMagick so please go easy on me. Been struggling trying to solve this problem for ages.
Here's the problem...
I have lots of images with transparent white backgrounds that have a few jaggy pointy bits round the edges here and there and I would like to remove these annoying areas altogether by perhaps using geometry to pinpoint each exact location then converting the pixels to transparent white or deleting the pixels altogether.
How would I do this? Any ideas anyone?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
Perhaps with a blur on the transparency.
If you want a less vague answer, you'll need to be less vague. Sample input and output images? What version of IM? On what platform?
If you want a less vague answer, you'll need to be less vague. Sample input and output images? What version of IM? On what platform?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I smooth out or delete pointy bits on the edge of an image
Perhaps what you want is the new -define for the -trim function. But you must be using ImageMagick 7. See
https://imagemagick.org/script/command- ... s.php#trim
viewtopic.php?f=4&t=35579
Be sure that you have transparency all around the image. If not add -bordercolor none -border 1 to your command
_______________________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
https://imagemagick.org/script/command- ... s.php#trim
viewtopic.php?f=4&t=35579
Be sure that you have transparency all around the image. If not add -bordercolor none -border 1 to your command
_______________________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
Further to my recent post...
My ImageMagick version is: 7.0.8-14 Q16 (64-bit) (2018-10-24)
Running on Windows 8.1 Pro
Thank you for your time and patience.
My ImageMagick version is: 7.0.8-14 Q16 (64-bit) (2018-10-24)
Running on Windows 8.1 Pro
Thank you for your time and patience.
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
If it helps any - the bits that I need to alter or remove come in all sorts of colors.
Thanks again for your time and patience.
Thanks again for your time and patience.
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
This is a scaled down version but hopefully you'll get the idea.
The pointy bits inside the red circles I need to smooth out somehow.
https://pasteboard.co/I7JmpMO.png
The pointy bits inside the red circles I need to smooth out somehow.
https://pasteboard.co/I7JmpMO.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I smooth out or delete pointy bits on the edge of an image
Sorry, that is a different issue all together. Post your original image without the red circles
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I smooth out or delete pointy bits on the edge of an image
try the following:
If in a .bat file, then % need to be doubled to %%.
The image you uploaded has no transparency or it was lost when you uploaded.
Code: Select all
convert image.png -gravity north -splice 0x100 ^
( -clone 0 -blur 0x100 -threshold 50% -negate ) ^
-alpha off -compose copy_opacity -composite ^
-background white -compose over -flatten ^
-gravity north -chop 0x100 ^
result.png
The image you uploaded has no transparency or it was lost when you uploaded.
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
That worked a treat but unfortunately I am unable to get it to work properly for the full image as that was just a section I uploaded.
Can you be so kind to do the exact same thing you did but this time for the full image.
The complete image is a head and I need to make the bit above the ears nice and rounded.
Here's the link to the file: https://pasteboard.co/I7L0ZXl.png
Thank you for your time and patience.
Can you be so kind to do the exact same thing you did but this time for the full image.
The complete image is a head and I need to make the bit above the ears nice and rounded.
Here's the link to the file: https://pasteboard.co/I7L0ZXl.png
Thank you for your time and patience.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I smooth out or delete pointy bits on the edge of an image
Try this. I extract the alpha channel. Then process it that same way. Then I make a mask that is white above the ears and black below. Then I use the mask to composite the alpha channel and the processed alpha channel together into one image. Then I use that to replace the alpha channel in the original image.
Code: Select all
convert image.png ^
( -clone 0 -alpha extract ) ^
( -clone 1 -blur 0x100 -threshold 61% ) ^
( -clone 1 -fill black -colorize 100 ( -size 2872x1524 xc:white ) -compose over -composite ) ^
( -clone 1-3 -compose over -composite -threshold 50% ) ^
-delete 1-3 ^
-alpha off -compose copy_opacity -composite ^
result.png
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
It's getting there.
But the part just above the ear on both sides 230px high and 30px wide needs to be addressed somehow.
Can the 30px that's been chopped off be returned or alternatively perhaps the 30px can removed right down to the ear.
Plus there's also the 50px vertical line at coordinates 2870, 1362px
Thanks again for your time and patience.
But the part just above the ear on both sides 230px high and 30px wide needs to be addressed somehow.
Can the 30px that's been chopped off be returned or alternatively perhaps the 30px can removed right down to the ear.
Plus there's also the 50px vertical line at coordinates 2870, 1362px
Thanks again for your time and patience.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I smooth out or delete pointy bits on the edge of an image
Sorry, that is the best I can do. You probably need to vectorize the image and then process the vectorized image to smooth it. Then re-rasterize it. So potrace, for example, for vectorizing.
-
- Posts: 9
- Joined: 2019-03-29T10:30:53-07:00
- Authentication code: 1152
- Location: Edinburgh, UK
Re: How do I smooth out or delete pointy bits on the edge of an image
I'm so sad that I cannot fix this properly. Is there not a way to zap the unwanted pixels and make them disappear?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I smooth out or delete pointy bits on the edge of an image
You would have to manually draw a mask image that was smooth at the top of the head. Then composite the mask with the image to trim away those pixels.
I suggest that you use and interactive tools such as GIMP or Photoshop to paint it smooth.
I suggest that you use and interactive tools such as GIMP or Photoshop to paint it smooth.