Page 1 of 1

Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-11T03:25:01-07:00
by vadim
I.e. can we have 2 colors, whose boundary will not be affected by intensity variants of morphology command? What's the exact formula for 'intensity'? It seems to be not

Code: Select all

0.299*red + 0.587*green + 0.114*blue
because with

Code: Select all

convert +antialias -size 200x200 xc:rgb(0%,100%,0%) -fill rgb(100%,70.263980%,0%) -font Cambria-Bold -pointsize 70 -gravity center -draw "text 10,10 'Hello'" -morphology dilatei disk:3 test_1.png
text is shrunk, but with

Code: Select all

convert +antialias -size 200x200 xc:rgb(0%,100%,0%) -fill rgb(100%,70.263981%,0%) -font Cambria-Bold -pointsize 70 -gravity center -draw "text 10,10 'Hello'" -morphology dilatei disk:3 test_1.png
text is widened. But, even if the formula is not a great secret, is there a case, in source code, that specially deals with equal intensities? Or maybe boundary between different colors will never stay in place?

Code: Select all

convert -version
Version: ImageMagick 6.9.1-1 Q16 x86 2015-03-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jbig jng jp2 jpeg lcms lqr openexr pa
ngocairo png ps rsvg tiff webp xml zlib

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-11T05:09:24-07:00
by snibgo
The intensity calculation depends on the current "-intensity" setting. For example, insert "-intensity RMS" before the morphology.

See http://www.imagemagick.org/script/comma ... #intensity

I don't know if the code treats two equal intensities but different colours any differently to equal colours. I suspect it doesn't. [EDIT: You could test this with "-intensity Brightness" that doesn't involve floating-point arithmetic.]

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-11T07:36:10-07:00
by vadim
Thanks a lot, it works exactly as you said. Boundaries between colors of the same intensity are not affected, and, yes, "Brightness" will suit perfectly, because image uses limited palette, and colors can be mapped to any set before processing and back afterwards.

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-12T12:00:12-07:00
by vadim
An update:
Boundaries between colors of the same intensity are not affected
Actually, the whole image is shifted, and result doesn't look right to me. Here is an exaggerated example:

Code: Select all

convert +antialias -size 200x200 xc:#00FF00 -fill #FF0000 -draw "rectangle 50,50,150,150" -fill black -draw "rectangle 80,20,120,180" test_1.png

convert test_1.png -intensity Brightness -morphology dilatei octagon:20 test_2.png
test_1.png:
Image
test_2.png:
Image

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-12T12:45:46-07:00
by snibgo
I would expect it to be symmetrical, as the ordinary "dilate" is. Perhaps this is a bug.

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-12T12:59:39-07:00
by fmw42
convert test_1.png -intensity Brightness -morphology dilatei octagon:20 test_2.png
This may just be a typo in your post, but dilate is misspelled as dilatei.

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-12T13:03:41-07:00
by snibgo
Whose post has "lidatei"? "dilatei" is short for "DilateIntensity".

Re: Intensity methods of morphology command -- can there be colors of the same 'intensity'?

Posted: 2015-07-12T15:50:31-07:00
by fmw42
snibgo wrote:Whose post has "lidatei"? "dilatei" is short for "DilateIntensity".
I have dislexia (of the fingers) when I type. :wink: It is fixed now in my comment.

Sorry, I had no idea IM accepted that abbreviation. I thought it was an extra character at the end.