Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive threshold produces poor image on Android #194

Open
rmdvector opened this issue Feb 6, 2024 · 8 comments
Open

Adaptive threshold produces poor image on Android #194

rmdvector opened this issue Feb 6, 2024 · 8 comments

Comments

@rmdvector
Copy link

rmdvector commented Feb 6, 2024

Testing our application that does image capture on a Google Pixel 7.
The code is basically straight out of the examples:
` let pipeline = gm.grayscale(im_mat);

pipeline = gm.adaptiveThreshold(

  pipeline,

  DEFAULT_ADAPTIVE_BOXSIZE_VALUE,    // 5

  DEFAULT_ADAPTIVE_THRESHOLD_VALUE,  // 15

  0 // grayscale channel only

)

const grayScale = gm.tensorFrom(pipeline)

const sess = new gm.Session()

sess.init(pipeline)

sess.runOp(pipeline, 0, grayScale)

sess.destroy()`

On desktop web (Chrome 119.0.6045.123), both our application and the example have the expected results.
However, on the Pixel, the image looks very fuzzy and full of artifacts. I tried the example for your page and saw the same results.

@rmdvector
Copy link
Author

I'm seeing this on both Mobile Chrome and Firefox

@rmdvector
Copy link
Author

Desktop Screenshot 2024-02-06 at 11 24 51 AM

Mobile:
Screenshot_20240206-112601

@WorldThirteen
Copy link
Contributor

Hi @rmdvector, there are a huge amount of factors that might impact the result, which include but are not limited to:

  • camera resolution
  • output resolution
  • video noise, sharpness
  • calculation precision available on the device GPU.

A good place to start is to prepare a sample with a single static image that runs and outputs in the same resolution on your target devices and compare it here. This might help determine if the issue is in the input source or in the calculation itself.

@rmdvector
Copy link
Author

Thanks for the quick response! Using identical code and browsers as above, here's the original image (edited to remove app-specific chrome):
PXL_20240207_213357677

Here's the image from the desktop web:
Screenshot 2024-02-07 at 1 45 18 PM

And here's the image from the phone:
Screenshot_20240207-134531

@rmdvector
Copy link
Author

Did github drop the images? if so is there a better way to transmit them?

@WorldThirteen
Copy link
Contributor

WorldThirteen commented Feb 9, 2024

@rmdvector, do you mean the code you provided in #194 (comment)?

Weird that GitHub has removed them, please try to re-post and I'll save them for records and further processing & debugging.

@rmdvector
Copy link
Author

303147243-b8d57fda-106b-4706-95b0-233b9f1b760f
Screenshot 2024-02-07 at 1 45 18 PM
303147378-4b0d3256-f16b-4136-a2c8-e7e9313c64fe

@WorldThirteen
Copy link
Contributor

@rmdvector, sorry for the lack of updates here, had not yet chance to take a look deeply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants