Page 1 of 1
Adjust line width
Posted: 2009-07-01T08:51:30-07:00
by mij
I have many hundreds of Black & White molecule diagrams. I want them all to have the same line width. Particulary, I would like to resize each image so the minimun line width is 1 pixel. Is it possible to accomplish this with imageMagick?
Thank you very much.
Re: Adjust line width
Posted: 2009-07-01T10:52:18-07:00
by fmw42
what do you mean by line width? are you talking about the width of the image or the thickness of linear features in the image. Are the images vector or raster? Converting raster images so that linear features are 1 pixel thick is very hard. You either get broken segments or thicknesses greater than 1. Morphologic filters are probably your only hope. See my script, morphology.
Can you post a link to an example image.
Re: Adjust line width
Posted: 2009-07-01T17:24:49-07:00
by anthony
I think we will need more information on exactly what you are trying to do before anyone can really help you.
Re: Adjust line width
Posted: 2009-07-02T07:36:59-07:00
by mij
I have several PNG images representing different chemical molecules. They are at different scales, for example:
Abacavir:
Acetohydroxamic acid:
I want the lines of both diagrams to have roughly the same thickness. I wonder if it is possible to automatize this task with imageMagick , given the -relatively- simple structure of the images, even if I know the problem is very hard.
fmw42, thank for your advise, I will test your script.
Re: Adjust line width
Posted: 2009-07-02T09:14:53-07:00
by fmw42
I tried a few things with my morphology script on your aceto.png image, but could not get anything appropriate for a result.
Re: Adjust line width
Posted: 2009-07-02T16:09:25-07:00
by mij
Thank you for your effort. I also tried your script with very little success.
My first thought was to somehow calculate the average thickness of the lines of the picture and scale it down consequently. Is that be possible?
Re: Adjust line width
Posted: 2009-07-02T21:14:32-07:00
by anthony
From what I can see you will somehow need to determine line thickness in images.
That can actually be quite hard to do, especially on a 'unknown' image.
Re: Adjust line width
Posted: 2009-07-02T21:58:06-07:00
by fmw42
Also your characters are all not the same thickness. That makes it harder, too.
Re: Adjust line width
Posted: 2009-07-06T18:44:56-07:00
by mij
Thank you for your time.
There are some peculiarities on the images that can be used to determine line width: For instance all images have lines at 36ยบ from the horizontal. I have studied image processing theory but have never done real programming besides some simple matlab stuff. What language/framework/... do you recommend me to use to program this ad-hoc algorithm?