'Image data of dtype object cannot be converted to float- Edge detection

I tried changing the data to np array also using uint8 but none helped. getting the same error. I have attached my error message as the comment. It is a grayscale image. the variables, image and res are both images used for edge detection- this is a use case code of Hough Transform.

  figure = plt.figure(figsize=(12, 12))
  subplot1 = figure.add_subplot(1, 4, 1)
  subplot1.imshow(image)

"""
TypeError                                 Traceback (most recent call last)
<ipython-input-71-1eee52901519> in <module>
     96     iterations=1
     97 )
---> 98 line_detection_non_vectorized(image, res)

<ipython-input-71-1eee52901519> in line_detection_non_vectorized(image, res, num_rhos, num_thetas, t_count)
     28   figure = plt.figure(figsize=(12, 12))
     29   subplot1 = figure.add_subplot(1, 4, 1)
---> 30   subplot1.imshow(image)
     31   subplot2 = figure.add_subplot(1, 4, 2)
     32   subplot2.imshow(res, cmap="gray")

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
   1445     def inner(ax, *args, data=None, **kwargs):
   1446         if data is None:
-> 1447             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1448 
   1449         bound = new_sig.bind(ax, *args, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, filternorm, filterrad, resample, url, **kwargs)
   5521                               resample=resample, **kwargs)
   5522 
-> 5523         im.set_data(X)
   5524         im.set_alpha(alpha)
   5525         if im.get_clip_path() is None:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\image.py in set_data(self, A)
    700         if (self._A.dtype != np.uint8 and
    701                 not np.can_cast(self._A.dtype, float, "same_kind")):
--> 702             raise TypeError("Image data of dtype {} cannot be converted to "
    703                             "float".format(self._A.dtype))
    704 

TypeError: Image data of dtype object cannot be converted to float """


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source