How to dilate foreground only if it's surrounded by background?

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?".
nicolai.rostov
Posts: 18
Joined: 2015-10-06T10:42:17-07:00
Authentication code: 1151

Re: How to dilate foregrouned only if it's surrounded by background?

Post by nicolai.rostov »

Yep, black and white, at least this is how the documentation makes me see what morphology (originally) sees as background and foreground.

On the other hand, doesn't IM already have a similar feature? How does the '-despeckle' operator decide what is, and what is not, a speckle? There must be a way to generalize this to other operations.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to dilate foreground only if it's surrounded by background?

Post by fmw42 »

From the code:


% DespeckleImage() reduces the speckle noise in an image while perserving the
% edges of the original image. A speckle removing filter uses a complementary
% hulling technique (raising pixels that are darker than their surrounding
% neighbors, then complementarily lowering pixels that are brighter than their
% surrounding neighbors) to reduce the speckle index of that image (reference
% Crimmins speckle removal).


So again simply looking at the graylevels of the neighborhood.

See effect.c at line 916
Post Reply