比较两个图像,并检查平等 [英] compare two images and check equality
问题描述
你知道任何有关AS3 /闪存内比较图像源或信息?
do you know any source or info about comparing images within as3/flash?
我要比较两个图像,并检查图像是相同的或没有。
I want to compare two images and check if the images are the same or not.
检查这个例子: http://imageshack.us/photo/my-images/825/imagecompare。 JPG /
任何线索?预先感谢您!
Any clues? Thank you in advance!
推荐答案
在除了重复的答案,
我相信你也可以使用<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#compare%28%29"相对=nofollow> BitmapData.compare()
从链接中抽取的,考虑下面两个BitmapData对象:
An example taken from the link, consider the following two BitmapData objects:
var bmd1:BitmapData = new BitmapData(50, 50, true, 0xFFFF8800);
var bmd2:BitmapData = new BitmapData(50, 50, true, 0xCCCC6600);
var diffBmpData:BitmapData = bmd1.compare(bmd2) as BitmapData;
trace ("0x" + diffBmpData.getPixel(0,0).toString(16); // 0x332200
code样品(用于百分比差值):
怎么不正确的结果,这是我酿造了一个个:
Don't how correct the results are, this is what I brewed up for a percentage :
var bmd1:BitmapData = new BitmapData(225, 225);
bmd1.draw(mc1);
var bmd2:BitmapData = new BitmapData(225, 225);
bmd2.draw(mc2);
var diffBmpData:BitmapData = bmd1.compare(bmd2) as BitmapData;
var diff:int = 0;
var total:int = 225 * 225;
for(var i=0; i<225; i++)
for(var j=0; j<225; j++)
diff += (diffBmpData.getPixel(i,j) != 0)? 1 : 0;
info.text = Math.round((diff / total * 100)).toString();
其中:信息是一个文本框, MC1 &放大器; MC2 是在第二阶段的影片剪辑。
where : info is a TextBox, mc1 & mc2 are two movieclips on stage.
我想你可以把它更好地比较各个值(即有多少不同的一个像素),而不是一个布尔值的是像素相似的匹配。
I think you can make it better by comparing individual values (i.e how much different a pixel is) rather than a boolean is-pixel-similar match.
结果:(白围绕着圆形图像空间将被包括在内)
Result: (White space around the round image would be included)
这篇关于比较两个图像,并检查平等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!