How to feather only cetain sides of an image?

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
ProGamer
Posts: 56
Joined: 2017-01-12T23:14:26-07:00
Authentication code: 1151

How to feather only cetain sides of an image?

Post by ProGamer »

How would I go about feathering only specific sides of an image?


Basically I did some feathering using a few different layers to combine a bunch of tiles, and arrived at this image:

Image

The problem is however that there are intersecting points on the outside edges, which aren't broken up by a feathered piece and thus sharply transition between tiles. The problem areas can be seen below:

Image

I have two images which I cropped with GIMP's feature, for fixing the transition areas:

Image

Image

Combined, these two pieces look like this, though only the tips are needed:

Image


I want to have the feathering only take place on each side of the "cross" tiles, and not on their tips.

I am using this command for the feathering:

Code: Select all

convert Input.png -alpha set -virtual-pixel transparent -channel A -morphology Distance Euclidean:1,50\! +channel Output_feathered.png

How can I accomplish this goal?

I am using, Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1038-aws x86_64), and ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31.
ProGamer
Posts: 56
Joined: 2017-01-12T23:14:26-07:00
Authentication code: 1151

Re: How to feather only cetain sides of an image?

Post by ProGamer »

For the layered tiling, I was using this:

A single tile in the center to fill in the small bit of missing image from the feathering in other layers:

Image

Then this set of 4 tiles in a plus/cross shape is composited ontop of the previous single tile layer (This is where the above cross sections that I only want to feathered the sides, come from):

Image

Finally, this set of 4 tiles in a 2x2 grid pattern, are placed ontop of the previously made two layer composite:

Image


I'm not sure if this is the most efficient/best way to ensure smooth transitions between tiles, but it's the best I've figured out so far.

I'm using this command for layering the images:

Code: Select all

convert Top_Input_Image.png Bottom_Input_Image.png -gravity <Desired Location> -composite Output_Image.png
The final step is using a non feathered version of the 2x2 tiles:

Image

And putting the layered composite from above, on top of it:

Image

While you cannot discern the individual tiles in the center region of the image, you can still see that abrupt transition between tiles on the edges, which is what I am trying to fix.
Last edited by ProGamer on 2018-01-19T19:50:25-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to feather only cetain sides of an image?

Post by fmw42 »

I am not sure I understand the issue. Can you be more succinct? What is the basic issue? If you have a tiled image that you only want feathered in certain areas. Then create a feathering mask and edit that to avoid the "safe" regions. Then use the mask to apply feathering against some background color such as white.
ProGamer
Posts: 56
Joined: 2017-01-12T23:14:26-07:00
Authentication code: 1151

Re: How to feather only cetain sides of an image?

Post by ProGamer »

fmw42 wrote: 2018-01-19T19:49:27-07:00 I am not sure I understand the issue. Can you be more succinct? What is the basic issue? If you have a tiled image that you only want feathered in certain areas. Then create a feathering mask and edit that to avoid the "safe" regions. Then use the mask to apply feathering against some background color such as white.

This might explain it better:


So I want to create something like this, where the feathering only goes from the center upwards or downwards (or left/right for the vertical section on the other piece):

Image

Using the specified command above, this is the output which is created:

Image

This is the input image I am trying to modify:

Image
ProGamer
Posts: 56
Joined: 2017-01-12T23:14:26-07:00
Authentication code: 1151

Re: How to feather only cetain sides of an image?

Post by ProGamer »

Code: Select all

convert Input.png -alpha set -virtual-pixel transparent -channel A -morphology Distance Euclidean:1,50\! +channel Output_feathered.png
From the morphology page located here: https://www.imagemagick.org/Usage/morphology/, I can't see a clear way of making sure the feathering gradient is only north/south or east/west, and not on all sides.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to feather only cetain sides of an image?

Post by fmw42 »

try this using a 1D linear vertical only blur of 20 pixels:

Code: Select all

convert test.png -alpha set -virtual-pixel transparent -channel A  -morphology Convolve Blur:20x65000+90 -level 50x100% +channel result.png
ProGamer
Posts: 56
Joined: 2017-01-12T23:14:26-07:00
Authentication code: 1151

Re: How to feather only cetain sides of an image?

Post by ProGamer »

fmw42 wrote: 2018-01-19T20:54:18-07:00 try this using a 1D linear vertical only blur of 20 pixels:

Code: Select all

convert test.png -alpha set -virtual-pixel transparent -channel A  -morphology Convolve Blur:20x65000+90 -level 50x100% +channel result.png
This appears to be the solution I was looking for. Thanks for the help!

The really visible line separating the tiles at the top center edge of the image is now gone, along with the visible line at the opposite location!

Image


Though how would I adjust the feathering so that the gradient would be more like the original feathering command I was using?


The new command:
Image

The old command:

Image

The gradient is pretty sharp compared to the original command.

Edit:

Using 50 pixels instead of 20 seems to do the trick, I think:

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to feather only cetain sides of an image?

Post by fmw42 »

try increasing the blur radius to 50 or adjust as seems to fit best your requirements.

Code: Select all

convert test.png -alpha set -virtual-pixel transparent -channel A  -morphology Convolve Blur:50x65000+90 -level 50x100% +channel result.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to feather only cetain sides of an image?

Post by snibgo »

You are feathering, which means you have a boundary that is straight but blurred across the overlapping area.

Another possibility is to have an irregular (non-straight) boundary that is sharp, but is chosen to be the jagged line that minimizes the difference between the two images within the overlapping area. This is known as "seam carving" or "minimum error boundary cut".

For example, see Awkward boundaries with dark paths and related pages.
snibgo's IM pages: im.snibgo.com
Post Reply