hello all...,
give it a solution tu use [convert -normalize] but ignore any edges of a image ?
for example:
only calculate 85% (yellow part) of the image and ignore 15% of the edges.
the result have to be like my image out.jpg, (but with the edges !!) .
my example image in.jpg , white or black areas (edges) can significantly skew the calculation of color balance if not ignored.
the wrong output is the same like the in-file
greetings from Switzerland
pet
convert -normalize , ignore edges without crop
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert -normalize , ignore edges without crop
"-normalize" builds a histogram and calculates from that what "-level" is required, and applies that "-level". (Internally, it doesn't use "-level", but takes a short cut to do the same thing.)
You want to crop your image for the "-normalize", but apply the "-level" to the entire image.
Sadly, the "-normalize" command can't tell you what "-level" is uses.
I think the best way is as follows:
1. Crop the image.
2. Normalize the crop.
3. Use the technique I show on my "Gain and Bias" page to find what "-level" was applied.
4. Apply that "-level" to the entire image.
You want to crop your image for the "-normalize", but apply the "-level" to the entire image.
Sadly, the "-normalize" command can't tell you what "-level" is uses.
I think the best way is as follows:
1. Crop the image.
2. Normalize the crop.
3. Use the technique I show on my "Gain and Bias" page to find what "-level" was applied.
4. Apply that "-level" to the entire image.
snibgo's IM pages: im.snibgo.com
Re: convert -normalize , ignore edges without crop
many thanks for the help.
i understand the point 1. and 2.
and i think i understand the way from 3. and 4.
on the hompage "Gain and Bias" i can see that i have to read the infos of the image, but i dont understand, how i can do it with (-level)
can you give me a example ?
or is necessary to develop a great script ?
i understand the point 1. and 2.
and i think i understand the way from 3. and 4.
on the hompage "Gain and Bias" i can see that i have to read the infos of the image, but i dont understand, how i can do it with (-level)
can you give me a example ?
or is necessary to develop a great script ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert -normalize , ignore edges without crop
Yes, it needs a script. My scripts are for Windows BAT. What do you use? BAT? Bash? Something else?
My scripts are quite complex because they cope with transparency in the input image, and they process the colour channels separately (to adjust colour balance). They can be simplified when the image is entirely opaque, and when you want to apply the same transformation to all three channels. Something like:
Do this for the crop, and for the normalized crop. These four numbers can be used to calculate the numbers for "-level".
My scripts are quite complex because they cope with transparency in the input image, and they process the colour channels separately (to adjust colour balance). They can be simplified when the image is entirely opaque, and when you want to apply the same transformation to all three channels. Something like:
Code: Select all
convert in.png -format "%[fx:mean] %[fx:standard_deviation]" info:
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert -normalize , ignore edges without crop
Here is a complete Windows BAT script. Adjust SRC and sCROP as required. The output is written to out.png. The line
... isn't required, and can be removed. It may be useful to check you are cropping the correct area, and that it normalizes well.
"-function Polynomial" takes parameters that are more convenient than "-level", but it has the same effect.
Code: Select all
+write x.png ^
"-function Polynomial" takes parameters that are more convenient than "-level", but it has the same effect.
Code: Select all
set SRC=toes.png
set sCROP=-gravity Center -crop 50%%x50%%+0+0 +repage
for /F "usebackq" %%L in (`%IM%convert ^
%SRC% ^
%sCROP% ^
-format "MN0=%%[fx:mean]\nSD0=%%[fx:standard_deviation]\n" ^
+write info: ^
-normalize ^
+write x.png ^
-format "MN1=%%[fx:mean]\nSD1=%%[fx:standard_deviation]\n" ^
info:`) do set %%L
for /F "usebackq" %%L in (`%IM%identify ^
-format "GAIN=%%[fx:%SD1%/%SD0%]\nBIAS=%%[fx:%MN1%-%MN0%*%SD1%/%SD0%]"
xc:`) do set %%L
%IM%convert %SRC% -function Polynomial %GAIN%,%BIAS% out.png
snibgo's IM pages: im.snibgo.com
Re: convert -normalize , ignore edges without crop
wow... thank for the script-example.
i work with linux (bash) but i think i can translate the windows- to the shell-bash script.
and try a picture
i work with linux (bash) but i think i can translate the windows- to the shell-bash script.
and try a picture
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert -normalize , ignore edges without crop
Translating to bash is trivial:
Code: Select all
SRC=toes.png
sCROP="-gravity Center -crop 50%%x50%%+0+0 +repage"
declare `convert \
$SRC \
$sCROP \
-format "MN0=%[fx:mean]\nSD0=%[fx:standard_deviation]\n" \
+write info: \
-normalize \
+write x.png \
-format "MN1=%[fx:mean]\nSD1=%[fx:standard_deviation]\n" \
info:`
declare `identify \
-format "GAIN=%[fx:$SD1/$SD0]\nBIAS=%[fx:$MN1-$MN0*$SD1/$SD0]" \
xc:`
convert $SRC -function Polynomial $GAIN,$BIAS g.png
snibgo's IM pages: im.snibgo.com
Re: convert -normalize , ignore edges without crop
thanks, it works perfect for me !
does exactly what I need
another question: can you make little 'IM' jobs for me ?
I still have some work where I have no solutions ....
I like to pay for good solutions
or you know who make it
pet
does exactly what I need
another question: can you make little 'IM' jobs for me ?
I still have some work where I have no solutions ....
I like to pay for good solutions
or you know who make it
pet