def compare_image_pixels(self, result_image, correct_result_image, threshold): self.fail_test_if_no_oiio() """ Given a file to find it results, compare it against the correct result. Returns None if the input is not an image. Returns oiio.CompareResults if results can be compared. """ compresults = oiio.CompareResults() ImageBufAlgo.compare(result_image, correct_result_image, threshold, threshold, compresults) return compresults
def doCompare(imgA='',imgB=''): bufB = oiio.ImageBuf() # get rid of extra channels in the di-matte image oiio.ImageBufAlgo.channels(bufB, oiio.ImageBuf(imgB), (0, 1, 2)) comp = oiio.CompareResults() oiio.ImageBufAlgo.compare(oiio.ImageBuf(imgA), bufB, 1.0e-6, 1.0e-6, comp) if comp.nwarn == 0 and comp.nfail == 0: return True else: return False
def doCompare(imgA='',imgB='',path = '',errorTol=0.01, warnTol = 1.0): comp = oiio.CompareResults() oiio.ImageBufAlgo.compare(oiio.ImageBuf(imgA), oiio.ImageBuf(imgB), errorTol, warnTol, comp) if comp.nwarn == 0 and comp.nfail == 0: return True else: # if path doesn't exist create it if not os.path.isdir(path): os.makedirs(path) pathFrame = path+ imgA[imgA.rfind('/')+1:imgA.rfind('.exr')]+'.jpg' diff=oiio.ImageBuf() oiio.ImageBufAlgo.absdiff(diff,oiio.ImageBuf(imgA),oiio.ImageBuf(imgB)) test = oiio.ImageBuf(oiio.ImageBuf(imgA).spec()) oiio.ImageBufAlgo.pow(test,diff,(.3,.3,.3,1.0)) test.write(pathFrame) return False
ImageBufAlgo.unpremult(b, b) write(b, "unpremult.tif") ImageBufAlgo.premult(b, b) write(b, "premult.tif") b = ImageBuf("../oiiotool/tahoe-small.tif") ImageBufAlgo.rangecompress(b, b) write(b, "rangecompress.tif", oiio.UINT8) ImageBufAlgo.rangeexpand(b, b) write(b, "rangeexpand.tif", oiio.UINT8) # FIXME - colorconvert, ociolook need tests # computePixelStats compresults = oiio.CompareResults() ImageBufAlgo.compare(ImageBuf("flip.tif"), ImageBuf("flop.tif"), 1.0e-6, 1.0e-6, compresults) print "Comparison: of flip.tif and flop.tif" print " mean =", compresults.meanerror print " rms =", compresults.rms_error print " PSNR =", compresults.PSNR print " max =", compresults.maxerror print " max @", (compresults.maxx, compresults.maxy, compresults.maxz, compresults.maxc) print " warns", compresults.nwarn, "fails", compresults.nfail # compare_Yee, # isConstantColor, isConstantChannel b = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8))