Skip to content

Unable to use function, ValueError: Input image doesn't have all values between 0 and 1. #6

@nrsprs

Description

@nrsprs

Issue:
Unable to prepare image to pass float 1-0 check without destroying image on write.

Expectation:
Convert to float and div by max(img), which is 255.0, to pass the np.all check in the beginning of the remove_reflection. Convert back to uint8 colorspace and write image.

Problem:
The image space divided by 255.0 is black. I'm trying to restore the image to the 0-255 colorspace, but that also doesn't seem to have an impact when writing to file; viewing inside of the imshow window shows the results as expected.

img = cv.imread("/Users/nick/Desktop/test.png")
if img is None:
    print("did not read")
    exit()

img = img.astype(np.float16)/float(img.max())

frrAlgo = FastReflectionRemoval(h = 0.14)
dereflected_img = frrAlgo.remove_reflection(img)

output = dereflected_img*255.0
output = output.astype(np.uint8)
cv.imshow("Output", output)
cv.waitKey(0)
cv.imwrite("/Users/nick/Desktop/output.png", dereflected_img)

I'm not sure what the best method for preparing images for is when using this function, or how they're supposed to be handled after processing. Would like to use this project since it seems very useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions