Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:46:12+00:00 2026-06-10T21:46:12+00:00

I have a byte array with series of 0 and -1 (255). It’s a

  • 0

I have a byte array with series of 0 and -1 (255). It’s a result of binarization using the Otsu algorithm. I used:

BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inDither = true;
opt.inPreferredConfig = Bitmap.Config.RGB_565; // I have tried ARGB_8888 aswell

Bitmap out = BitmapFactory.decodeByteArray(data, 0, data.length, opt);

Unfortunately, it returns null. Just like the other questions regarding BitmapFactory.decodeByteArray().

I have tested other methods like nested for loops, it works but it takes too long to process, especially for large images.

This is what I currently use to generate the binarized data:

ptr = 0;
while (ptr < srcData.length)
{
    monoData[ptr] = ((0xFF & srcData[ptr]) >= threshold) ? (byte) 255 : 0;
    ptr ++;
}

I hope you can lead me to a better way on solving this issue. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:46:14+00:00Added an answer on June 10, 2026 at 9:46 pm

    565 is a representation that uses 2 bytes per pixel.

    Moreover, decodeByteArray is a method that reads a compressed byte[] (see documentation).

    Here is what I would do :

    • use a int[] rather than a byte[].
    • initialize like follows
    • use Bitmap.html#createBitmap() method with the int[] resulting. The config used is not really important at this point.


    monoData[ptr] = ((0xFF & srcData[ptr]) >= threshold) ? 0xffffffff : 0xff000000;

    nota : one thing that could have helped you : decodeByteArray has no idea of the geometry of your image, hence can of course not decode it to what you are expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some numbers, encoded in byte array using variable-length code. Actually it's GIF89a
I have a byte array with RTP packets in it. I am not using
I have a byte array which needs to be marshalled into the following struct:
I have a byte array and I need to convert this to a image.
I have a byte array, received from java application via network. I need to
I have a byte array highlighted below, how do I insert it into a
I have a byte array filled from a file uploaded. But, in another part
I have a byte array that may or may not have null bytes at
I have a byte array of around 10,000 bytes which is basically a blob
I have a byte array of size 4 byte[] source = new byte[4]; Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.