Extend Pixels to replace some values

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
lilith
Posts: 8
Joined: 2010-10-06T23:37:50-07:00
Authentication code: 8675308

Extend Pixels to replace some values

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Extend Pixels to replace some values

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply