0

Origin Image

0 0 0
0 1 0
0 0 0

generated by:

$ convert -size 3x3 xc:black -fill white -draw 'point 1,1' origin.png

Dilation Process

Use a 2x1 rectangle as the kernel with central point (0,0):

processed by:

$ convert origin.png -morphology Dilate Rectangle:2x1+0+0 output.png

Expected Output

0 0 0
1 1 0
0 0 0

Actual Output

0 0 0
0 1 1
0 0 0

Question

Why the output is unexpected? I wonder how ImageMagick processes dilation.

Here is my understanding:

When the kernel's central point iterates to the position (0,1) of the original image:

I thought (0,1) should have been 1 after AND operations.

Weihang Jian
  • 7,826
  • 4
  • 44
  • 55

1 Answers1

-1

The "center point" of a 2x1 kernel is between pixels. So you have to choose which one is the official "origin". It is arbitrary. But you can set the origin in ImageMagick when defining the kernel. See https://imagemagick.org/Usage/morphology/#user

For example for a 2x1 kernel, it could be either

2x1+0+0: 0,1

or

2x1+1+0: 0,1


fmw42
  • 46,825
  • 10
  • 62
  • 80
  • down voted because you did not answer the question. – Weihang Jian Nov 22 '19 at 02:21
  • `@ Jian Weihang` You are harsh, but at least honest enough to sign your name to it. I thank you for that. The question is irrelevant since ImageMagick has a method to set it the way you want. Who can say why the other tools chose the other default or which might be correct. It was an arbitrary choice as I said. – fmw42 Nov 22 '19 at 17:40