Morphology prune

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Morphology prune

Post by snibgo »

(IM version 6.6.0-8 Q16 on Windows 7.)

The documentation talks about a "prune" kernel, but it doesn't work:

convert in.png -channel alpha -morphology erode:3 prune -background blue -flatten out.jpg

convert: UnrecognizedKernelType `prune' @ error/convert.c/ConvertImageCommand/1968.

Can I prune lines with one or more user-defined convolution kernels?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Morphology prune

Post by fmw42 »

I have not played much with the IM morhphology function. But what exactly do you mean by prune? see viewtopic.php?f=1&t=15692&p=56385&hilit ... ine#p55890 for removing 1 pixel wide vertical or horizontal lines
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Morphology prune

Post by snibgo »

The morphology usage page http://www.imagemagick.org/Usage/morphology/ under "Morphology Introduction" shows 6 kernels, including "prune". The text says:
Also note how the second last kernel [prune] not only has a 'on' value but also an 'off' value as as part of its 'shape'. Both values are important to the Hit-n-Miss method (see below), while this specific kernel is one of a number used for 'pruning' the ends of lines within images.
I'm interested in using it to progressively shrink the length of lines, creating a sequence that I would reverse in a movie so the lines would grow.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Morphology prune

Post by fmw42 »

out of curiosity could you post a link to one of the images you want to prune.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Morphology prune

Post by snibgo »

This is part of (ie a crop from) a frame of a video. It is mostly transparent, and shows a number of black lines adjacent to white lines. Morphology, applied to the alpha channel, can erode the black/white lines.

Image
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Morphology prune

Post by fmw42 »

are you trying to make the lines shorter or thinner? if the latter then why not just use erode?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Morphology prune

Post by snibgo »

Yes, erode works fine to make them thinner. I want to make them shorter.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Morphology prune

Post by fmw42 »

OK, thank. I guess we need to wait to here from Anthony.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Morphology prune

Post by anthony »

Prune is not yet implemented, and is waiting for me to have time to implement the very complex method it is based on Hit-n-Miss. Other operators that also need Hit-n-Miss is Thicken and Thinning.

The method itself is not complex, but to allow it to be used by later operators it needs to be able to handle not just one kernel but a list of kernels (usually two or more kernels with rotations). This in tern makes the method not so straight forward to handle, though some 'hooks' have been planned for.

In other words it is just just a simple patch but needs more programming effort, and thus needs a block of time to program. Especially if you don't want to 'break' the existing operators in the process.

I have similar 'time' problems for the implementation of grid and mesh, distortions which also require a similar level of additional complexity to be added.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply