I have used Tensorflow’s DecodeJpeg
to read image while training a model. In order to use the same method on an android device, I compiled Tensorflow with bazel for android with DecodeJpeg
.
I tried reading the same image on my desktop, which is an x86_64
machine that runs windows. I ran the DecodeJpeg
method on an image with default values with dct_method
set to ''
, INTEGER_FAST
, INTEGER_ACCURATE
.
I did the same on an arm64
device, for the same image. But, the pixel values were significantly different for the same image under the same settings.
For instance, at (100,100,1) the value on desktop is 213
, while it is 204
on arm64
.
How can I make sure that the pixel values are same across these two devices?[![This is the image I have used][1]][1]
Update:
On Gimp at (100,100)
the pixel values are (179,203,190)
For dct_method
set to INTEGER_FAST
, the value at (100,100)
on x86_64 is (171, 213, 165)
, on arm it is (180, 204, 191)
For dct_method
set to INTEGER_ACCURATE
, the value at (100,100)
on x86_64 is (170, 212, 164)
, on arm it is (179, 203, 190)
It is (170, 212, 164)
with PIL
, which is what I get with cv2.imread
as well.
According to tensorflow image decode_jpeg documentation
I expect that it may be relative to some attribute when you decode the jpeg.
Most probably the channels
attribute and/or the ratio
attribute and/or the fancy_upscaling
attr.
Both of them can change the value of the pixel…
Concerning the channels
:
The attr channels indicates the desired number of color channels for the decoded image.
Accepted values are:
0: Use the number of channels in the JPEG-encoded image. 1: output a grayscale image. 3: output an RGB image.
Concerning the ratio
:
The attr ratio allows downscaling the image by an integer factor during decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than downscaling the image later.
Concerning the fancy_upscaling
:
fancy_upscaling: An optional bool. Defaults to True. If true use a slower but nicer upscaling of the chroma planes (yuv420/422 only).
Please note that you may also have to explicitly specify a value for the dct_method
because according to documentation, if you don’t specify a value it will use a system-specific defaut .
And in my opinion, it (the dct_method empty arg) is the most probable reason which explain why you don’t have same result on x86_64 and ARM.
the internal jpeg library changes to a version that does not have that
specific option
Tags: androidandroid, image, tensorflow