Page 1 of 1
Blurring edges of images to match white background
Posted: 2016-11-22T09:13:41-07:00
by tbayle
I have thousands of furniture renderings of various sizes and JPG's, all shot on a white floor with shadows. I want to post these images on my web site which has a white page background. The problem is the edges of the images are not truly white because of the shadows. What I'm looking to do is feather the edges so the shadows fade to match the white background. I can add additional size to the images to accomplish this if necessary. I'm new to IM and not sure what commands to research to accomplish this goal. Any advice would be welcomed. Running on Windows platform, can script in DOS or Perl. Running 6.7.2-9 IM.
Re: Blurring edges of images to match white background
Posted: 2016-11-22T09:25:19-07:00
by snibgo
Your inputs are JPG, which have no transparency. I suppose you want the same for your outputs?
So, you have an object surrounded by roughly white. You want to change the background, so it fades to exactly white at the edges of the image. Is that correct?
There are many ways of doing this. For example, if you know there are always at least 20 pixels around the image, you could fade over that distance. Or you could find the boundary of the object, and gradually fade from there to the edges of the image.
Perhaps you can put a sample at somewhere like dropbox.com and paste the URL here.
Re: Blurring edges of images to match white background
Posted: 2016-11-22T10:01:41-07:00
by GeeMack
tbayle wrote:What I'm looking to do is feather the edges so the shadows fade to match the white background. I can add additional size to the images to accomplish this if necessary.
One way to accomplish this is to make a clone of your input image, clear it to transparent, add a thick white border, blur the border, then composite that clone with blurry border back onto the input image. Something like this will give the result you describe for a single input image...
Code: Select all
convert input.jpg -alpha on ^
( +clone -virtual-pixel none -distort affine "0,0 %[w],0" ^
-virtual-pixel tile -bordercolor white -shave 30x30 -border 50x50 -blur 0x10 ) ^
-gravity center -composite output.jpg
Maybe run something like that in a "for" loop to process a whole directory of JPGs. If used in a Windows BAT script, any single percent sign "%" will have to be made into a double "%%" of course.
Re: Blurring edges of images to match white background
Posted: 2016-11-22T12:00:36-07:00
by tbayle
snibgo - thank you for the quick reply. Yes JPG as output is desired. Yes I want it to fade exactly to white at the edges of the image. We control the crop of the image so we can insure there's always sufficient space between the edge and actual object. Or additional border can be added if that is better/easier.
Here's a link to a dropbox folder with an example image.
https://www.dropbox.com/sh/4mibp578dd4s ... V9Nia?dl=0