Hi all,
Can anyone give me some guidance (or lead me in right direction) on how Fred's stain glass script could be modified so that cell color uses average color of cell and not point sample? This script is amazing but I need more accurate color representation for my purposes.
I am referring to this: http://www.fmwconcepts.com/imagemagick/ ... /index.php
I appreciate any help.
Stained Glass effect using average color
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stained Glass effect using average color
As an approximation, just blur the input image with a square size uniformly weighted convolution (-morphology convolve WxH:1 1 1 1 .....) or with a circular shaped uniformly weighted blur (-blur radx65000). For example,
Input:

# default size is 16
stainedglass -r 100 -k random -b 150 -t 1 -r 56 birdofparadise.gif birdofparadise_sg.png

#circular blur of radius=8
convert birdofparadise.gif -blur 8x65000 birdofparadise_b8.png

# default size is 16
stainedglass -r 100 -k random -b 150 -t 1 -r 56 birdofparadise_b8.png birdofparadise_b8_sg.png

To do it exactly, would be very time consuming and would really require that this script be implemented as a function of IM. But to script it, you would have to make a mask for each cell (one at a time), use the mask to get the average colors (see http://www.fmwconcepts.com/imagemagick/ ... shape_mean), then flood fill the region with the mean color. The repeat for each other cell. Then composite all the images together.
If the blur concept is acceptable, I can build it into the script as an option.
Input:

# default size is 16
stainedglass -r 100 -k random -b 150 -t 1 -r 56 birdofparadise.gif birdofparadise_sg.png

#circular blur of radius=8
convert birdofparadise.gif -blur 8x65000 birdofparadise_b8.png

# default size is 16
stainedglass -r 100 -k random -b 150 -t 1 -r 56 birdofparadise_b8.png birdofparadise_b8_sg.png

To do it exactly, would be very time consuming and would really require that this script be implemented as a function of IM. But to script it, you would have to make a mask for each cell (one at a time), use the mask to get the average colors (see http://www.fmwconcepts.com/imagemagick/ ... shape_mean), then flood fill the region with the mean color. The repeat for each other cell. Then composite all the images together.
If the blur concept is acceptable, I can build it into the script as an option.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stained Glass effect using average color
One can even make shaped averages using -morphology, such as for an octagon shape we would have -morphology Convolve Octagon:N where N is the octagon shape argument that would need to be matched to the desired cell size. You can do squares, diamonds, octagons and circles.
Re: Stained Glass effect using average color
Interesting solution blur. I would never have thought of this. I really like the idea of shaped averages using -morphology. I'm going to get working on this approach.
Thank you so much for the detailed response!
Thank you so much for the detailed response!