On Thu, 08 Jan 2009 11:48:38 +0100 Cedric Pinson <[email protected]> wrote:
| Hi Anthony, | | I will try to answer inline because i am not sure i understand all details | | | I dont understand why you are saying what i did is pure luck :) | because i put the original alpha mask of the original image on the final | because i dont want the alpha mask changed in final image. Are you | saying that | my use of morphology is not correct to expand the ? in this case i will | understand. | Could you send me your circle_halves.png in order i test with it to see | the result | | anyway if you have a morphology that dont touch the alpha mask it will | avoid me to extract | and copy the original image mask to the final alpha_mask. | | | Maybe i miss something, can you point me precisely where i am wrong ? | thank you for your helps and suggestion. | | Cheers, | Cedric | | Anthony Thyssen wrote: | > On Wed, 07 Jan 2009 21:01:13 +0100 | > Cedric Pinson <[email protected]> wrote: | > | > | Hi, | > | | > | Here the script i use it seems to work fine for all my cases right now, | > | i will try on futur data and tell if it works | > | for most cases | > | | > | #!/bin/bash | > | set -e | > | set -x | > | file=$1 | > | filewithoutext=$(echo $1 | sed 's/.png//g') | > | name=$(basename $1 | sed 's/.png//g') | > | ./morphology -m grayscale -t erode -i 1 $file /tmp/${name}_0.png | > | convert $file -alpha extract /tmp/${name}_alpha.png | > | composite -gravity center $1 /tmp/${name}_0.png /tmp/${name}_2.png | > | convert /tmp/${name}_2.png /tmp/${name}_alpha.png -alpha off -compose | > | Copy_Opacity -composite ${filewithoutext}_final.png | > | | > I can see the results your script produces using my "circle_halves.png" | > test image. though there appears to be a couple of unusual extraneous | > pixels. in the results. | > | Could you send me your picture in order i test please | > However I would not depend on morphology from expanding (or contracting) | > the image mask as you are using it for. What should do is undefined, | > and in fact logically it is doing the oppisite of what it should be doing. | > | Yes that's why i dont use the result of alpha mask from morphology i use | the original | because i want the mask not changed. But maybe i miss something in this | line: | | composite -gravity center $1 /tmp/${name}_0.png /tmp/${name}_2.png | | > The fact that it does so is pure luck. I just submitted back to Fred | > a improved and about 7 times faster version of grayscale morphology, | > however it does not erode/dilate the transparency mask of the image! | > | It's better for sure | > I suggest you extract the alpha mask first, the dilate it separatally. | > | that's why i do or again maybe my composite line i miss something. | > ASIDE: the new version also has the interative blur spreading operator | > that I developed in the previous email. | > | > I'll include a copy of that script to you. | > | > Fred.... Please note there is a small change to the previous one so this | > version does at least preverse transparency in greyscale morphology. The | > previous one wiped out transparency rather than preserve it. | > | > | If i understand correctly you are saying is for this line: | | composite -gravity center $1 /tmp/${name}_0.png /tmp/${name}_2.png | | /tmp/${name}_0.png should not have the mask extended from morphology is | that correct ? | or did i miss other thing ? | Basically you pass the original image to morphology, and then you extract the alpha channel from the result. As I mentioned how the alpha channel is effected was not looked at in the scripts original design. In fact due to the nature of IM (storing transparency as 'matte' values rather than 'alpha' values the morphology script does the reverse of what I would expect. In IM v7 which would use 'alpha' values, that will probably change. Basically I am saying we can not gurantee the images alpha mask will expand under an erode operation, either due to a change in how morphology is implemented, OR how the IM programs deal with it. It is undefined! As such you are achieving a result which may not always be correct. The best idea is to extract the alpha channel and the colors and deal with these aspects separately. This will ensure you deal with the alpha channel correctly regardless of how the morphology operator is implemented. Anthony Thyssen ( System Programmer ) <[email protected]> ----------------------------------------------------------------------------- Hi! I'm a shareware signature! Send $5 if you use me, send $10 for manual! ----------------------------------------------------------------------------- Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/ _______________________________________________ Magick-users mailing list [email protected] http://studio.imagemagick.org/mailman/listinfo/magick-users
