Page 4 of 5
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:00:49-07:00
by fmw42
This does not finish for me on IM 6.6.9.7. So I think your version of IM is faulty.
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null:
Furthermore, my result on a current version of IM gives different values than what you said.
So I think you need to upgrade your version of IM.
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:01:54-07:00
by newbie1
Should i upgrade my imgaemgaick to version 6.7.8?
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:05:36-07:00
by fmw42
newbie1 wrote:Should i upgrade my imgaemgaick to version 6.7.8?
I just checked and my 6.6.9.7 was not installed. So I cannot say for sure that your version of IM is bad.
The only indication I have is that my result from
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null:
143.673 (
0.00219231) @ 32,20
is not the same as yours. If you get a return value that is the same, then your unix may be missing the sed command and that could be why it is not returning anything.
This works for me and returns:
value=`compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
echo "$value"
0.00219231
Double check both again and let me know what you get.
If you type
man sed
does that give you the man pages for sed? Or does it say there is no sed command?
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:10:55-07:00
by newbie1
It get me to the man pages for sed.
I think it really is my version of imagemagick. So, i will now update to version 6.7.8
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:11:58-07:00
by fmw42
newbie1 wrote:It get me to the man pages for sed.
I think it really is my version of imagemagick. So, i will now update to version 6.7.8
Get the latest version 6.7.8.9.
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:13:38-07:00
by newbie1
The latest is 6.7.8.10 should i install that?
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:32:34-07:00
by fmw42
newbie1 wrote:The latest is 6.7.8.10 should i install that?
Sure, that should be fine.
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:42:47-07:00
by newbie1
I don't think i can install the lastest version as my ubuntu synaptic latest version is 6.6.9-7
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:45:44-07:00
by fmw42
I just installed IM 6.7.8.10 and I get this:
compare -metric rmse -subimage-search rose: xc:red null:
143.673 (0.00219231) @ 32,20
compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'
0.00219231
If that does not work, try
compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | tr -cs ".0-9\n" " " | cut -d\ -f 2
0.00219231
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T20:46:25-07:00
by fmw42
newbie1 wrote:I don't think i can install the lastest version as my ubuntu synaptic latest version is 6.6.9-7
I do not know what to tell you. try
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null:
143.673 0.00219231 32 20
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null: 2>&1 | tr -cs ".0-9\n" " " | cut -d\ -f 2
0.00219231
If that does not work, can you back down to earlier releases of IM?
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-12T22:04:34-07:00
by newbie1
Finally it works!
I updates my imagemagick to the latest version.
The script is:
Code: Select all
#!/bin/sh
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<0.022?1:0]" info:`
if [ $test -eq 1 ]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
But there a problem. Its very very slow. When i start the script, it takes about 35 seconds for it to finish.
Is there any way to reduce the time taken ?
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-13T11:06:39-07:00
by fmw42
newbie1 wrote:Finally it works!
I updates my imagemagick to the latest version.
The script is:
Code: Select all
#!/bin/sh
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<0.022?1:0]" info:`
if [ $test -eq 1 ]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
But there a problem. Its very very slow. When i start the script, it takes about 35 seconds for it to finish.
Is there any way to reduce the time taken ?
You can try to use my script, norcrosscorr, but that requires IM in Q16 HDRI mode. It uses FFT to do fast correlation. See also
http://www.fmwconcepts.com/imagemagick/ ... mcrosscorr
You might get a bit speed up by using a simpler error measure than rmse. see
http://www.imagemagick.org/Usage/compare/#statistics
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-13T18:42:54-07:00
by newbie1
After testing out different error measure, i realised that the script take too long to finish is because of "-subimage-search".
So, i took out "-subimage-search", but after tooking it out, there an error that say the width and height of the small and large image is different.
Then, I use the OldID and crop out everything except the word "STUDENT".(student1.jpg)
After testing it out, The RMSE difference is too little.
But i found 2 error measure that has quite a difference.
The first one is NCC.
The error between the student1.jpg and oldID.jpg is
The error between the student1.jpg and newID.jpg is
However, after putting it into the script, there is an error. It is able to run but the output is wrong.
Code: Select all
#!/bin/sh
value=`compare -metric NCC newID.jpg student1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<0.065?1:0]" info:`
if [ $test -eq 1 ]; then
convert 4.jpg newid.jpg
else
convert 4.jpg oldid.jpg
fi
The second one is AE -fuzz 10%
The error between the student1.jpg and oldID.jpg is
The error between the student1.jpg and newID.jpg is
The same error occur when i run this script. It is able to run but the output is wrong.
Code: Select all
#!/bin/sh
value=`compare -metric NCC newID.jpeg student1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<420000?1:0]" info:`
if [ $test -eq 1 ]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
What is wrong in the script?
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-13T19:22:59-07:00
by fmw42
What is the error message when running the script?
I suspect the sed command is likely not doing the right thing, because the output from compare is now different.
compare -metric rmse rose: \( -size 70x46 xc:red \) null:
28533 (0.435386)
But
compare -metric NCC rose: \( -size 70x46 xc:red \) null:
0
This does not look right. I would expect some difference. But only one value in the range 0 to 1. I suspect one gets zero here because there is not one single pixel in the rose image that is exactly red.
This gives a perfect match thought there is some precision issue that cause the result to be slightly larger than 1.
compare -metric NCC rose: rose: null:
1.00031
Likewise
compare -metric AE -fuzz 10% rose: \( -size 70x46 xc:red \) null:
3220
This is only giving the raw counts. This is probably correct with only one value. It is not normalized and so is going to be image size dependent, unless you divide by the total pixels in the image.
You have to understand that different error measure produce different output. So sed is not finding any parenthesis to locate the value in the parenthesis.
For these measures, just take out the sed command.
value=`compare -metric AE -fuzz 10% image1 image2 null: 2>&1`
Re: [HELP] Autocrop batch on photo ID
Posted: 2012-08-13T19:34:03-07:00
by newbie1
Ther is error mesage is:
Code: Select all
convert: missing expression `' @ error/fx.c/FxEvaluateSubexpression/2111.
/home/user/123/test1.sh: 4: [: -eq: unexpected operator
But there is still a output and the output is awalys newid.jpg which is in the else statement.