trying to rotate vector image based on angle histogram
Posted: 2015-11-01T04:43:58-07:00
I have not used ImageMagick recently and just downloaded and built the latest release but was not able to figure out
how to achieve a specific result although I did find some features, like those related to hough lines in the link at bottom,
that may be close.
I've got an image source that has a really nice API although I have not found documentation it
appears to generate high quality png images, easily converted to pnm, with some parameters but the only ones
I know about right now are size,
https://pubchem.ncbi.nlm.nih.gov/image/ ... height=512
Ideally it would return vector images with some angles variable as that is the nature of the cartoon chemical structure but I can probably
work with png using potrace as shown below ( CON points to imagemagick convert in my development
directory),
$CON "$DEST" -trim -threshold 80% "xxx"
$CON "xxx" -trim "$DESTPNM"
potrace -b pgm -a -10 -T 0 -B 0 -L 0 -R 0 "$DESTPNM"
potrace -b pdf -a -10 -T 0 -B 0 -L 0 -R 0 "$DESTPNM"
potrace -b eps -a -10 -T 0 -B 0 -L 0 -R 0 "$DESTPNM"
In this specific image, the long "chain" is apparently oriented to be along a diagonal but as I wish
to put many of these images into a latex document, I'd like to rotate this and make the chain horizontal.
I can probably do this if I have a histogram of vector angles but not sure how to get that from "identify"
or other utility. I suppose the ellipse angles would be a help, and that was what I considered using, but
that is just an average distorted by the ring component. Is there some way to dump just a raw list
of vector length and orientation? If I can compute an optimal rotation angle for a given
object ( making the chain part horizontal in this and related molecular images ) that would
be even better.Thanks.
Maybe using data like this?
viewtopic.php?t=25476
how to achieve a specific result although I did find some features, like those related to hough lines in the link at bottom,
that may be close.
I've got an image source that has a really nice API although I have not found documentation it
appears to generate high quality png images, easily converted to pnm, with some parameters but the only ones
I know about right now are size,
https://pubchem.ncbi.nlm.nih.gov/image/ ... height=512
Ideally it would return vector images with some angles variable as that is the nature of the cartoon chemical structure but I can probably
work with png using potrace as shown below ( CON points to imagemagick convert in my development
directory),
$CON "$DEST" -trim -threshold 80% "xxx"
$CON "xxx" -trim "$DESTPNM"
potrace -b pgm -a -10 -T 0 -B 0 -L 0 -R 0 "$DESTPNM"
potrace -b pdf -a -10 -T 0 -B 0 -L 0 -R 0 "$DESTPNM"
potrace -b eps -a -10 -T 0 -B 0 -L 0 -R 0 "$DESTPNM"
In this specific image, the long "chain" is apparently oriented to be along a diagonal but as I wish
to put many of these images into a latex document, I'd like to rotate this and make the chain horizontal.
I can probably do this if I have a histogram of vector angles but not sure how to get that from "identify"
or other utility. I suppose the ellipse angles would be a help, and that was what I considered using, but
that is just an average distorted by the ring component. Is there some way to dump just a raw list
of vector length and orientation? If I can compute an optimal rotation angle for a given
object ( making the chain part horizontal in this and related molecular images ) that would
be even better.Thanks.
Maybe using data like this?
viewtopic.php?t=25476