Edge() with unacceptable artefacts
Edge() with unacceptable artefacts
Hello,
I want to make edge images from geometric gray scale images (with a Perlmagick subprogram) but I get
unacceptable artefacts. I used the edge-function in non geometric contexts a lot and I did not care
about the artefacts there but in the geometric context it becomes unacceptable. Is the edge-function
in IM so bad or how could I avoid the artefacts? It would be an ugly media discontinuity to use
Win PS for the edge generation (which works perfectly) in an otherwise Linux IM workflow.
example (I have tried to smooth the arefacts, but none the less it is unacceptable):
source image: http://www.flickr.com/photos/gbachelier/12701896523/
edge image: http://www.flickr.com/photos/gbachelier/12701729855/
I want to make edge images from geometric gray scale images (with a Perlmagick subprogram) but I get
unacceptable artefacts. I used the edge-function in non geometric contexts a lot and I did not care
about the artefacts there but in the geometric context it becomes unacceptable. Is the edge-function
in IM so bad or how could I avoid the artefacts? It would be an ugly media discontinuity to use
Win PS for the edge generation (which works perfectly) in an otherwise Linux IM workflow.
example (I have tried to smooth the arefacts, but none the less it is unacceptable):
source image: http://www.flickr.com/photos/gbachelier/12701896523/
edge image: http://www.flickr.com/photos/gbachelier/12701729855/
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Edge() with unacceptable artefacts
The artefacts are caused by fine detail in the source image. Perhaps that detail shouldn't be there, and the data should be black and white, but some fool has saved it as JPG.
You can remove the fine detail with threshold. As a command:
You can remove the fine detail with threshold. As a command:
Code: Select all
convert 12701896523_c359b7a3e6_o.jpg -threshold 50% -edge 2 e.png
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: Edge() with unacceptable artefacts
try using -morphology edgein diamond:1, it works for me on IM 6.8.8.7 Q16 Mac OSX Snow Leopard in command line.
It produced a cleaner edge than using -edge.
The issue is that your image is not binary (it has antialiasing or fuzzy edges) and needs to be thresholded appropriately before using -edge.
Code: Select all
convert 12701896523_c48135e0f9_k.jpg -morphology edgein diamond:1 result.png
The issue is that your image is not binary (it has antialiasing or fuzzy edges) and needs to be thresholded appropriately before using -edge.
Re: Edge() with unacceptable artefacts
Code: Select all
convert 12701896523_c48135e0f9_k.jpg -morphology edgein diamond:1 result.png
Now I need to integrate it in PerlMagick, but the description of the method Morphology on http://www.imagemagick.org/script/perl-magick.php
Morphology kernel=>string, channel=>{All, Default, Alpha, Black, Blue, CMYK, Cyan, Gray, Green, Index, Magenta, Opacity, Red, RGB, Yellow}, iterations=>integer
makes it not obvious for me how the right syntax may be. Perhaps: $image->Morphology(kernel=>'edgein', diamond=>'1');
Thanks for further help.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Edge() with unacceptable artefacts
Sorry, I do not know PerlMagick. But I suspect you need another command. That seems to suggest that it is asking for which channel to operate on. There must be a higher level command that calls this command. Otherwise, the docs are wrong.
Re: Edge() with unacceptable artefacts
I tried a workaround where I write the image, construct a $systemstring with "-morphology edgein diamond:", call the system from Perl with $systemstring and Read the result image to work with it in my processing pipeline. After some initial tries this ugly workaround is now working, but I posted a question how to map "-morphology edgein diamond:1" in PerlMagick to avoid this.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Edge() with unacceptable artefacts
I do not know Perlmagic, but did you try (just a guess)
$image->Morphology(kernel=>'edgein diamond:1', channel=>"all");
$image->Morphology(kernel=>'edgein diamond:1', channel=>"all");
Re: Edge() with unacceptable artefacts
no, I got a "Failed to parse kernel number #0" error and image is unchanged.fmw42 wrote: $image->Morphology(kernel=>'edgein diamond:1', channel=>"all");
Re: Edge() with unacceptable artefacts
PerlMagick for
is
Code: Select all
convert img.png -morphology edgein diamond:1 result.png
Code: Select all
$img->Morphology(method=>'edgein', kernel=>'diamond', channel=>'all', iterations=>'1');