Python Forum
???Can not convert from <U25 to float64.???
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
???Can not convert from <U25 to float64.???
#1
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.
Reply
#2
I see in the doc that the expected argument for img_as_float() has type ndarray, not str.
Reply
#3
(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.
Reply
#4
Try:
image = skimage.img_as_float('ceta').
Reply
#5
(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
Reply
#6
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?
Reply
#7
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  numpy.float64 object is not iterable jcdr91 1 13,147 Apr-22-2020, 04:09 PM
Last Post: jefsummers
  ValueError: Input contains infinity or a value too large for dtype('float64') Rabah_r 1 12,840 Apr-06-2019, 11:08 AM
Last Post: scidam
  numpy.float64 and plot_date in matplotlib iv20023 1 5,698 Jun-21-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020