Morphology effect

Use the morphology effect to thin or thicken edge boundaries in an image. This effect creates a kernel that is 2 times the Width and Height values you specify. This effect centers the kernel on the pixel it is calculating and returns the maximum value in the kernel (if dilating) or minimum value in the kernel (if eroding).

The CLSID for this effect is CLSID_D2D1Morphology.

Example images

This example shows the output of the effect when using the erode mode.

Before
The image before the effect.
After
The image after the transform.

 


ComPtr<ID2D1Effect> morphologyEffect;
m_d2dContext->CreateEffect(CLSID_D2D1Morphology, &morphologyEffect);

morphologyEffect->SetInput(0, bitmap);

morphologyEffect->SetValue(D2D1_MORPHOLOGY_PROP_MODE, D2D1_MORPHOLOGY_MODE_ERODE);
morphologyEffect->SetValue(D2D1_MORPHOLOGY_PROP_WIDTH, 14);

m_d2dContext->BeginDraw();
m_d2dContext->DrawImage(morphologyEffect.Get());
m_d2dContext->EndDraw(); 

Effect properties

Display name and index enumerationType and default valueDescription

Mode

D2D1_MORPHOLOGY_PROP_MODE

D2D1_MORPHOLOGY_MODE

D2D1_MORPHOLOGY_MODE_ERODE

The morphology mode. The available modes are erode (flatten) and dilate (thicken).

See Morphology modes for more info.

Width

D2D1_MORPHOLOGY_PROP_WIDTH

UINT

1

Size of the kernel in the X direction. The units are in DIPs. Values must be between 1 and 100 inclusive.

Height

D2D1_MORPHOLOGY_PROP_HEIGHT

UINT

1

Size of the kernel in the Y direction. The units are in DIPs. Values must be between 1 and 100 inclusive.

 

Morphology modes

NameDescription
D2D1_MORPHOLOGY_MODE_ERODEThe maximum value from each RGB channel in the kernel is used.
D2D1_MORPHOLOGY_MODE_DILATEThe minimum value from each RGB channel in the kernel is used.

 

Output bitmap

For DILATE mode, the Output Bitmap size grows:

Output Bitmap Growth X =INT(FLOAT(Width) * ((User DPI) / 96))
Output Bitmap Growth Y =INT(FLOAT(Height) * ((User DPI) / 96))

 

For ERODE mode, the Output Bitmap size shrinks:

Output Bitmap Growth X =INT(FLOAT(-Width) * ((User DPI) / 96))
Output Bitmap Growth Y =INT(FLOAT(-Height) * ((User DPI) / 96))

 

Requirements

Minimum supported clientWindows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Minimum supported serverWindows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Headerd2d1effects.h
Libraryd2d1.lib, dxguid.lib

 

Related topics

ID2D1Effect

 

 

Show: