You need to convert the image to 255 and uint8, and then turn back.
real_image = cv2.cvtColor(real_image,cv2.COLOR_GRAY2RGB)
real_image = cv2.resize(real_image,(256,256))
real_image *= 255
real_image = real_image.astype(np.uint8)
real_image = cv2.applyColorMap(real_image, cv2.COLORMAP_HOT)
real_image = np.asarray(real_image/255, dtype=np.float32)
Read More:
- Opencv: How to Draw Palette
- [Perfectly Solved] attributeerror: module ‘SciPy. Misc’ has no attribute ‘toimage’ error
- For the problem of rejecting old usage errors after numpy is updated, modified in numpy 1.20; for more details and guidance
- [Solved] Python Error: An attempt has been made to start a new process before the current process has finished …
- CV: How to extracts the part of the picture with the specified color
- Opencv Python realizes the paint filling function in PS, one click filling color and the possible reasons for opencv’s frequent errors
- [How to Fix] TypeError: Cannot cast array data from dtype(‘float64‘) to dtype(‘<U32‘)….
- [Solved] RuntimeError: scatter(): Expected dtype int64 for index
- [Solved] RuntimeError: gather(): Expected dtype int64 for index
- RuntimeError: Non RGB images are not supported [How to Fix]
- [Solved] python opencv Error: findContours() Can only use the Grayscale
- IndexError: list index out of range [How to Solve]
- [Solved] cv2.error: (-215:Assertion failed) encoder->isFormatSupported(CV_8U) in function ‘imwrite_‘
- Python writes DICOM file (attributeerror: ‘filemetadataset’ object has no attribute ‘transfersyntax uid’ solution)
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘astype‘
- Error:output with shape [1, 224, 224] doesn‘t match the broadcast shape [3, 224, 224]
- Solution warning: userwarning: fixedformatter should only be used together with fixedlocator (illustrated version)!)
- [Solved] RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dim
- [Solved] ufunc ‘add‘ did not contain a loop with signature matching types (dtype(‘<U32‘), dtype(‘<U32‘))