How to get coodinates of border to txt file

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

How to get coodinates of border to txt file

Post by VanGog »

I am Windows user. I have image, where I have deleted background and would like to get the edge of image into txt file. I mean, there would be need to make inner border to the image, which is 1px wide, and then to write the x,y coordinates to txt file. For example, if I have picture of figure with removed background, I would get the edge of the picture. I believe, it would not be hard to do it with help of border function. But what if the image is more hard, and has more empty areas like a ladder? Would it be possible to separate every empty area (inner borders would be separated as loops)? Then the output could have x,y list followed by empty line, then next x,y list , and so on. I am interested if this would be possible. I would like to use the list in macro to use in one program.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to get coodinates of border to txt file

Post by fmw42 »

Make everything black that you want to get coordinates for and the rest white. Then in unix you could do

convert image txt:- | tail -n +2 | grep "black"

I do not know if Windows supports pipes, tail or grep. But see
http://www.imagemagick.org/Usage/files/#txt
http://www.imagemagick.org/Usage/windows/
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: How to get coodinates of border to txt file

Post by VanGog »

What function to use to generate inner border around the areas that are not empty?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to get coodinates of border to txt file

Post by fmw42 »

VanGog wrote:What function to use to generate inner border around the areas that are not empty?

either -edge or -morphology edgin

you may need to threshold the result to make binary black/white
Post Reply