1

I have a jpg format picture:

enter image description here

And I want to extract the rgb value from every pixel , but I found that the values are diiferent from Android and Photoshop .

Like the first pixel(x=0,y=0) , the rgb value which androidTest got is 216,231,238 while photoshop is 217,230,238.

enter image description here

Here are my android codes:

    InputStream inputStream =  appContext.getAssets().open("small_"+ pictureNum +".jpg");
    bitmap = BitmapFactory.decodeStream(inputStream);
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int color;
    int red, green, blue;

    List<Short> pixelList = new ArrayList<>();

    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            color = bitmap.getPixel(x, y);

            pixelList.add((short) Color.red(color));
            pixelList.add((short) Color.green(color));
            pixelList.add((short) Color.blue(color));

        }
    }

I am using Android Studio 3.1.2 .

android {
compileSdkVersion 26



defaultConfig {
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}}
JDChi
  • 240
  • 3
  • 18
  • Try to convert it to a png and check if you have still different values. Your differences are small, so it is possible it is just a precision error on decoding the jpg data (or also precision vs. speed). I do not think it is a problem of AdobeRGB (the luminous values should have larger differences). – Giacomo Catenazzi Apr 30 '18 at 10:08
  • Note: jpg is usually a format that lose information, and reduce quality. So 2 over around 760 (3*256) is really nothing. On most cases human eyes will not see differences. – Giacomo Catenazzi May 01 '18 at 07:52

0 Answers0