def image_compare(output, err):
    m = re.search('\\[[\\d, -]*\\]', output)
    self.assertIsNotNone(m, ('Failed to find proper image output in: ' + output))
    js_data = eval(m.group(0))
    js_data = [(x if (x >= 0) else (256 + x)) for x in js_data]
    true_data = bytearray(open(path_from_root('tests', 'openjpeg', 'syntensity_lobby_s.raw'), 'rb').read())
    assert (len(js_data) == len(true_data))
    num = len(js_data)
    diff_total = js_total = true_total = 0
    for i in range(num):
        js_total += js_data[i]
        true_total += true_data[i]
        diff_total += abs((js_data[i] - true_data[i]))
    js_mean = (js_total / float(num))
    true_mean = (true_total / float(num))
    diff_mean = (diff_total / float(num))
    image_mean = 83.265
    assert (abs((js_mean - image_mean)) < 0.01), [js_mean, image_mean]
    assert (abs((true_mean - image_mean)) < 0.01), [true_mean, image_mean]
    assert (diff_mean < 0.01), diff_mean
    return output
def image_compare(output, err):
    m = re.search('\\[[\\d, -]*\\]', output)
    self.assertIsNotNone(m, ('Failed to find proper image output in: ' + output))
    js_data = eval(m.group(0))
    js_data = [(x if (x >= 0) else (256 + x)) for x in js_data]
    true_data = bytearray(open(path_from_root('tests', 'openjpeg', 'syntensity_lobby_s.raw'), 'rb').read())
    assert (len(js_data) == len(true_data))
    num = len(js_data)
    diff_total = js_total = true_total = 0
    for i in range(num):
        js_total += js_data[i]
        true_total += true_data[i]
        diff_total += abs((js_data[i] - true_data[i]))
    js_mean = (js_total / float(num))
    true_mean = (true_total / float(num))
    diff_mean = (diff_total / float(num))
    image_mean = 83.265
    assert (abs((js_mean - image_mean)) < 0.01), [js_mean, image_mean]
    assert (abs((true_mean - image_mean)) < 0.01), [true_mean, image_mean]
    assert (diff_mean < 0.01), diff_mean
    return output