tags: Road to Cultivation: Python
In the process of python image processing, the value of the RGB image encountered is between 0-255. In order to process the image better, the image value is usually converted to between 0-1
This process is the process of converting the uint8 type of the image to the float type.
img.astype('uint8')/255
The range of common types:

Python recommends the following two types of images:
from PIL import Image
import numpy as np
im = Image.open('test.jpg') # From reading is uint8
npim = np.array(im) # Convert to numpy array processing
import cv2
im = cv2.imread('test.jpg') # Read the default numpy array in uint8 format
In general, uint8 can be used directly, if there is a need (such as neural network, etc.), it can be converted into floating-point numbers. If you need to convert back to the PIL image object, it must be in uint8 format. If you always use cv2, you can also directly save the floating-point number form (note that it is 0~255, not 0~1).
reference:
When using numpy to create a matrix (numpy.ndarray) and want to use it to generate a picture, you must remember that the type of each element in the matrix must be dtype=np.uint8 or you can write dtyp...
1. ‘float’ to ‘float64’ x x xIt was originally a "float" type After the above x x xIt becomes the "float64" type 2. From "float64" to "float&...
Python INT8 INT16 INT32 INT64 FLOAT UINT8 INT8, accounting for 1 byte. INT16, accounting for 2 bytes. int32, 4 bytes. int64, 8 bytes. Float type value range: -1 to 1 or 0 to 1 uint8 Type Value range: ...
In go language, byte is actually an alias of uint8, and byte and uint8 can be directly converted between each other. Currently, only int in the range of 0 to 255 can be converted to byte. When using b...
25, 'float', for converting the integer to floating point and string. ...
When reading a date from an Excel, it is found to be a float type, but it is a date when it is displayed. This will be handled in the code, and the conversion is conversion: This is the string after t...
Recently, I want to use Python better, so I decided to sort out the basic knowledge. The code comes from the source code and analyzed the official documentation. Reference document:https://docs.python...
Just as a record, please skip. use.astype The Train_Images array is an integer of the UINT8 type (if the obtained value will be taken from the integer), the blogger wants to turn it into float, and th...
ImportWhen the image is used, the matlab read image data type is saved as uint8 (8-bit unsigned integer); In operationThe value in matlab generally uses double type (64 bit); Display imageWhen (imshow...
Digital image processing Matlab image data type uint8, double relationship (1) The double-type image matrix is converted to the uint8(I) type. (2) Display of [0, 1] and [0, 255] of the image Matlab ...