Hello,
i scan cd booklets and i put these booklets on a neon-green piece of paper (background) before scanning. However, these booklets unfortunately do not have a straight cut on the sides. so after trimming the image you can see neon-green pixels at the frame of the trimmed image. But because i have this neon green background as a trigger-color, i believe it's easier to replace this as you find this color hardly in the image itself. However i want to do the following thing:
Is it possible to only replace a color in a certain area of an image? In my case this would be the outer 5 pixels (border) of my images. If that is possible i would not have to double check if it accidentally replaced the color also in the image itself, because it would only apply to the outer five pixels.
thank you very much for your help
Replace Color only in specific area of an Image
-
- Posts: 2
- Joined: 2013-06-05T05:35:31-07:00
- Authentication code: 6789
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Replace Color only in specific area of an Image
You could make your changes as you do now to the entire image, then copy and paste the areas you want unmodified back in. Alternatively, you could use -floodfill to make your changes so that only areas connected to the outside are changed.
-
- Posts: 2
- Joined: 2013-06-05T05:35:31-07:00
- Authentication code: 6789
Re: Replace Color only in specific area of an Image
how could such a comandline look like? i did not find anything regarding to replacing colours in the manpage under -floodfill
my current commandline is the following
convert input.jpg -crop \
`convert input.jpg -virtual-pixel edge -blur '0x15' -fuzz '15%' \
-trim -format '%wx%h%O' info:` +repage -background 'insert neon color here' -rotate '-90' +repage -deskew '40%' +repage -fuzz "40%" -trim +repage -bordercolor 'white' -border '10' +repage output.jpg
my current commandline is the following
convert input.jpg -crop \
`convert input.jpg -virtual-pixel edge -blur '0x15' -fuzz '15%' \
-trim -format '%wx%h%O' info:` +repage -background 'insert neon color here' -rotate '-90' +repage -deskew '40%' +repage -fuzz "40%" -trim +repage -bordercolor 'white' -border '10' +repage output.jpg
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Replace Color only in specific area of an Image
This example is silly, but it gives you an idea of both methods.
(Windows batch, adjust as needed.)
The first line does a floodfill, which may be useful for making your color replacement. The second line limits the affected area for extra safety. If you need to limit to a non-rectangular area, you need a mask.
If you need more specific ideas, an example image would help.
Code: Select all
convert ^
logo: -fuzz 5%% -fill red -floodfill +0+0 white ^
( logo: -gravity center -crop 90x90%%+0+0 ) -composite ^
_.png
The first line does a floodfill, which may be useful for making your color replacement. The second line limits the affected area for extra safety. If you need to limit to a non-rectangular area, you need a mask.
If you need more specific ideas, an example image would help.