Home > Enterprise >  How to check if Image Data can be returned from a Dictionary?
How to check if Image Data can be returned from a Dictionary?

Time:06-28

I am currently writing a Python module, in one portion of the function I am saving a tiff image to a dictionary. However I am not sure how to actually validate that this is happening? How do I call or return the array from the dictionary the tiff file is saved in? Do I simply need to end my function with return optional_dict?

optional_dict={}
if showMaps==True:#Conditional argument for saving the tiff image
    #Tiff image saved in a temporary directory
    with open(outputdir f"ROI-{NAME}-thickness_tif", 'rb') as f:
        thickness_tif = f.read()# Read tiff image
    thickness_tif = optional_dict["thickness_tif"] #Save to dictionary with keyword

CodePudding user response:

If you want to save thickness_tif to a dictionary optional_dict, you have to reverse the expression:

# Save to dictionary with keyword
# INCORRECT: thickness_tif = optional_dict["thickness_tif"]
optional_dict["thickness_tif"] = thickness_tif

And if you want to check what was written, you may simply print the value stored in your dictionary:

print(optional_dict["thickness_tif"])
  • Related