[EMAIL PROTECTED] on wrote...
| Greetings All,
|
| Here is my setup:
| Windows XP Pro, ImageMagick 6.2.6 Q16
|
| Here is my task:
| Remove gray background from JPG image. Image has anywhere from 5 to
| 30 different shades of gray:
|
| #DCDCDC
| #DADADA
| #DBDBDB
| ...
| #DFDFDF
| ...etc
|
| Attempted solution:
| Using basic convert replaces specified color
| convert -fill White -opaque #DFDFDF
|
| I found -fuzz option to nail all those shades of gray but don't understand
| how to use it.
|
|
As part of 6.2.6-2 development, I had problems involving the fuzzy
matching of colors, so I am probably at this moment in a very good
position to report on just way 'fuzzy' matching means.
The test routine was throughtly debugged because of this in the latest
release.
The fuzz factor, represents a 'similarity' match in multi-dimensional
spherical distance between colors, using whatever color space the image
is using.
Well okay lets try that in plain english. You have a color X, Y will
be treated as being similar (same as) X if the distance between these
two colors is less than the fuzz factor.
A fuzz of 200 represents a distance of 200 units in the current color
depth of the IM being used, for a IM Q16 (16 bit quality for color
store) this is quite small, for a IM Q8 this is VERY large, and will
match a lot of colors.
Using a fuzz factory as a percentage represents the percentage of the
MaxRGB for this IM. As such, a fuzz factor of 50% is 128 in IM Q8
and a distance of 32768 in IM Q16.
At this level Navy Blue and Blue will be just equivelent, but Red and
Blue will still be thought of as different.
In RGB space a -fuzz of 100% will just match Red with Black, but Red not
with Blue! For these colors to match you will need a fuzz factor of the
square root of 2, or about 142%. For White and Black (eg
all colors) to match you will need a fuzz factor of the square root of
3, or about 174%.
Color matching is actually much more consistant if the image was stored
using some other color scheme than RGB.
Fuzzy matching becomes more complicated when matching transparent and
semi-transparent colors (this is where I was having problems for the
last release).
As of version 6.2.6-2, fully-transparent colors will always match as
being the same, no matter what the RGB component.
Comparing semi-transparent colors results in the distance between the
RGB color components being halved.
This improves comparisions between image with transparencies, and also
color reduction for images with some semi-transparency, with less
semi-transparent colors being generated in color reductions.
| Could someone suggest proper command to capture all those gray colors
| in one command?
Are the greys the outside borders of the jpeg?
Do you wnat them cleared?
Does the other parts of the image contain greys?
Any their any grey 'holes' that should also be matched?
Are the edges sharp, anti-alised, or do they have a gradient of greys?
These questions are important to consider when trying to match a area
based on color. It is a very difficult matter, especially with JPEG
images which do not save colors exactly (eg it uses a lossy
compression).
For some schemes I have documented so far see...
Re-adding Transparency to an Image
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/channels/#mask_creation
Recovering an Image Overlay
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/compare/#overlay
GIF background transparency
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/formats/#bgnd
You may also be interested in a technique involving color gradients,
by Rick Mabry....
Replacement of color with blending to preserve antialiasing
http://www.lsus.edu/sc/math/rmabry/imagemagick/multireplace/
| ================================================================
|
|
| I wanted to do it all in PERL as well as I have a lot of images to process.
| There is "identify" command which reports all colors in an image.
| Trouble is, while for some images I get nice report like this:
|
| Histogram:
| 1: (218,218,218) #DADADA
| 5: (219,219,219) grey86
| 1085: (221,221,221) #DDDDDD
| 497: (220,220,220) gainsboro
| 28826: (222,222,222) grey87
| 1274: (223,223,223) #DFDFDF
| 10: (225,225,225) #E1E1E1
| 398: (224,224,224) grey88
|
|....
|
| and no color report.
|
No color report will be generated if their are more than 1024 colors.
For a guranteed report look at
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/files/#histogram
Anthony Thyssen ( System Programmer ) <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
A file is private because the person who created it says so...
If anyone else were to decide, they would have to look at it, and then
it woundn't be private, would it? -- John Barnes, "Orbital Resonance"
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users