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

json_to_dataset fails if image is mono 16-bit #1528

Open
Kees-van-der-Oord opened this issue Jan 14, 2025 · 0 comments
Open

json_to_dataset fails if image is mono 16-bit #1528

Kees-van-der-Oord opened this issue Jan 14, 2025 · 0 comments

Comments

@Kees-van-der-Oord
Copy link

Provide environment information

with latest labelme_json_to_dataset.py script and the .exe as well

What OS are you using?

windows 10

Describe the Bug

script fails with 'data type must be np.uint8'
the problem is solved by adding this code before label2rgb():

import numpy as np

img = imgviz.asgray(img)

asgray does NOT convert mono (gray) 16-bits to 8-bits

so do it here:

if img.dtype != np.uint8:
    img =  (img/(np.max(img)/256)).astype('uint8')

lbl_viz = imgviz.label2rgb(
    lbl, img, label_names=label_names, loc="rb"
)

Expected Behavior

the script should be able to handle mono 16-bit images

To Reproduce

run the script with a json file with a 16-bit image

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

1 participant