-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ReadFile.readBitmap alters image colors #87
Comments
On some devices, this is causing the following tests to fail in ReadFileTest: testReadFile_jpg |
The tests have been fixed but the ReadFile problems remain. The following tests are now failing: testReadBitmap (the alpha value is apparently read incorrectly for the 1x1 bitmap) |
From my minor testing on this, I am wondering if these tests are failing because of "Java_com_googlecode_leptonica_android_ReadFile_nativeReadBitmap" converting the 32-bit bitmap image to a 8-bit grayscale image? The alpha data of the image is discarded, so I'm guessing the internal RGBA representation has an alpha value that is not equal to the full opaque value? I'm not totally sure. I can do more testing on this issue, but in any case, would you be opposed to me modifying the aforementioned function so that it creates a Pix with the full 32-bit data, instead of grayscale? The code I mentioned is here: |
I think changing the function to return a Pix with the full 32-bit data would be fine, and worth doing. Yes it does look like the alpha data is currently discarded. Hmm, it looks like there's a version in renard314's version of the repo that may be worth testing and using: https://github.com/renard314/tess-two/blob/master/tess-two/jni/com_googlecode_leptonica_android/readfile.cpp#L141 I see there's a function called |
This did end up fixing all those failing tests- I used renard314's version. I hope that's okay. |
Actually, upon second look, this might have introduced another issue- I'm now getting: com.googlecode.leptonica.android.test.JpegIOTest > testCompressToJpeg[XT907 - 4.4.2] FAILED Let me test this some more. Sorry for the confusion- that'll teach me to think I've won too early. Edit: this was just caused by me forgetting to change Pix's depth from 8 to 32. So that's fixed, but other tests now fail because of alpha issues. I'll work on getting all fixed. |
cherry-pick readfile.cpp that always produces 32-bit pix from renard314 source: https://github.com/renard314/tess-two/blob/bb8b785d79810cbc97dbe5147a75c90714b2abca/tess-two/jni/com_googlecode_leptonica_android/readfile.cpp
I have fixed this and similar WriteFile tests in my fork, which uses Tesseract 4.0. Should I create a special Pull Request for these changes, or maybe it would be wise to move the whole project to Tesseract 4.0 ? |
My preference would be to first have pull requests or a single PR to fix this issue and the other similar issues, so that I could tag a release and publish a version on Bintray with those fixes for users who want to have the bug fixes but don't want to upgrade to Tesseract 4.0 yet. |
Feel free to cherry-pick the relevant commits. Note that no changes to tesseract or leptronica sources were not involved. I will be away from computers for about a week, but if you need my help I will do my best on return from this short vacation. |
cherry-pick readfile.cpp that always produces 32-bit pix from renard314 source: https://github.com/renard314/tess-two/blob/bb8b785d79810cbc97dbe5147a75c90714b2abca/tess-two/jni/com_googlecode_leptonica_android/readfile.cpp cherry-pick alexcohn/Tesseract4Android@12edb77
ReadFile.readFile and ReadFile.readMem seem to be changing white to gray.
The text was updated successfully, but these errors were encountered: