Python Forum

Full Version: ???Can not convert from <U25 to float64.???
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import numpy as np
import matplotlib.pyplot as plt
import scipy as sc
import scipy.ndimage as ndi

from scipy.ndimage import gaussian_filter
from skimage import data
from skimage import img_as_float
from skimage.morphology import reconstruction


image = img_as_float('1332_Camera_Ceta_0001.tif')
Error:
ValueError: Can not convert from <U25 to float64.
So I messed up early on. But I have no idea what <U25 is (any tips?)
Or how to solve this...Please help.
I see in the doc that the expected argument for img_as_float() has type ndarray, not str.
(Aug-22-2018, 07:46 AM)Gribouillis Wrote: [ -> ]I see in the doc that the expected argument for img_as_float() has type ndarray, not str.

Thank you very much for your help. I loaded the fill as follows

image = img_as_float(data.ceta())
i the error I received was
Error:
AttributeError: module 'skimage.data' has no attribute 'ceta'
"CETA" is the name of the file. I changed the name for practicality. So I don't understand the error. I am very new to using Python.
Try:
image = skimage.img_as_float('ceta').
(Aug-22-2018, 03:42 PM)Anysja Wrote: [ -> ]Try:
image = skimage.img_as_float('ceta').

I am affraid that even this way I receive the following message from the console

Error:
File "<ipython-input-30-bc40eb0231f2>", line 1, in <module> img = skimage.img_as_float('ceta') File "C:\Python\anaconda\lib\site-packages\skimage\util\dtype.py", line 378, in img_as_float64 return convert(image, np.float64, force_copy) File "C:\Python\anaconda\lib\site-packages\skimage\util\dtype.py", line 121, in convert .format(dtypeobj_in, dtypeobj_out)) ValueError: Can not convert from <U4 to float64.
And I dont understant what "<U4" means either Sad
It seems as though the skimage.img_as_float is working, however it may be a different size than the float64? I am not entirely sure. I found this online:

Byte order is: >
Size is: 4
Name of data type is: int32
The type specifier (i4 in above case) can take different forms:

b1, i1, i2, i4, i8, u1, u2, u4, u8, f2, f4, f8, c8, c16, a
(representing bytes, ints, unsigned ints, floats, complex and
fixed length strings of specified byte lengths)
int8,…,uint8,…,float16, float32, float64, complex64, complex128
(this time with bit sizes)

It could possibly be converting it to a float32?
I've found an online example with the following line
image = skimage.img_as_float(skimage.io.imread(x)).astype(np.float32)
where I think x is a filename. You could perhaps try something similar. I don't use these modules, so I cannot help more.