Page 1 of 1

[SOLVED]How avoid smudged edges produced from B&W silhouette

Posted: 2013-03-07T05:07:48-07:00
by yougo
Hi,

I am using IM version 6.6.9-7 in Ubuntu Linux.
I have an image that I pre-processed using the following command:

Code: Select all

convert $image_file -colorspace Gray $gray_image

Code: Select all

convert $gray_image -threshold 80% $bw_image

Code: Select all

convert $bw_image -morphology Smooth Octagon:3  $clean_bw_image
I now want to take the resulting B&W silhouette and generate the edge.
I have tried the following commands:

Code: Select all

convert $bw_image -edge 2 -negate $edge_bw_image
convert $clean_bw_image -negate -edge 2 -negate $edge_bw_image
convert $clean_bw_image -edge 1 -negate $edge_bw_image
convert $clean_bw_image -negate -morphology EdgeIn Diamond -negate $edge_bw_image
convert $clean_bw_image -negate -morphology Edge Diamond -negate $edge_bw_image
As far as I can see, the B&W silhouette prior to edge detection, has a clean border with
no speckles or smudges. However, after edge detection the edges is smeared with
pixels. Is there any way I can generate "clean" edges? The examples in the IM site
don't seem to have this problem.

The following link show the files in question:
Original image:https://www.dropbox.com/s/o2wtirbc4ym3i25/original.jpg
Image after pre-processing:https://www.dropbox.com/s/vgafcn8noa1yl8n/clean_bw.jpg
The (smudgy) result:https://www.dropbox.com/s/w1wdvod9jh4wuv0/edge_bw.jpg

TIA,
Hugo

Re: How to avoid smudged edges produced from B&W silhouette

Posted: 2013-03-07T10:20:19-07:00
by fmw42
I suspect your version of IM is buggy and certainly very old (140 versions old). The following works fine for me under IM 6.8.3.7 Q16 Mac OSX Snow Leopard.


convert original.jpg -set colorspace RGB -colorspace gray -threshold 80% -morphology smooth octagon:3 -negate -morphology edgeout diamond:1 result.jpg


I suggest you upgrade your version of IM

Re: How to avoid smudged edges produced from B&W silhouette

Posted: 2013-03-08T04:17:37-07:00
by yougo
I have gone through the hoops and made a "local" installation of the latest version of IM.
The results don't show those artifacts anymore. That seemed to solve the issue.

BTW, why do we need the " -set colorspace RGB"?
I made several tests and their seem to be no differences in the output.

Thanks for suggestion.

Re: [SOLVED]How avoid smudged edges produced from B&W silhou

Posted: 2013-03-08T10:17:11-07:00
by fmw42
BTW, why do we need the " -set colorspace RGB"?
Perhaps that is not needed when you use -threshold. But for versions of IM after IM 6.8.0.3 grayscale images are treated as linear and will display darker than they did before that version. To make them look the same as before (non-linear grayscale) on has to tell IM that the image is not nonlinear sRGB color before converting to grayscale or it will apply a gamma transformation to make it darker.

See
viewtopic.php?f=4&t=21269

Also
viewtopic.php?f=3&t=22758

Re: [SOLVED]How avoid smudged edges produced from B&W silhou

Posted: 2013-03-11T05:53:40-07:00
by yougo
Thank you.

Re: [SOLVED]How avoid smudged edges produced from B&W silhou

Posted: 2013-03-17T19:03:59-07:00
by anthony
the smugs look more like JPEG errors you get from trying to save binary images using a JPEG image encoding.

JPEG does not handle sharp edges very well due to its lossy compression algorithm.

Re: [SOLVED]How avoid smudged edges produced from B&W silhou

Posted: 2013-03-19T02:13:40-07:00
by yougo
Anthony,

Ok, I will test test this with the png formats although results from the latest IM were not too bad.

Thanks,