Page 1 of 1

Extend Pixels to replace some values

Posted: 2011-12-31T03:40:34-07:00
by lilith
Hello,

I would like to extend a value of a pixel to the border of the image, which have to replace all 0,0,0 pixels. I would like to test different directions (from left/right, or top/bottom). To illustrate :

It's the original image : http://imageshack.us/photo/my-images/44 ... r4rgb.png/
Pixels extended to left/right : http://imageshack.us/photo/my-images/44 ... 4xrgb.png/
Pixels extended to top/bottom : http://imageshack.us/photo/my-images/32 ... 4yrgb.png/

I'm under Windows. Big thanks in advance.

Cheers.

Re: Extend Pixels to replace some values

Posted: 2012-01-02T23:43:46-07:00
by anthony
Tricky problem. Though I suggest you change your examples so the 'original' did not show the effect you are after. It makes the example a little confusing.

I thought of some morphology techniques but they did not work well.

The best I achieved was using a distance map using a special user designed neighbourhood.
http://www.imagemagick.org/Usage/morpho ... tance_user

This was then used as a FX image map
http://www.imagemagick.org/Usage/mappin ... ement_maps
which defined which 'edge' pixel the color should come from, but I had to apply it once for the 'left' and one for 'right' directions.

The result is a sort of limited neighbourhood diffusion of the edge colors across the transparent parts of the image I used.

It however is far from petty, and would need a lot more work before I would publish it here.