This is the 19th day of my participation in the Genwen Challenge

Image recognition

,

After sampling and quantization, image I has been called a digital image with discrete spatial position and response value. Each position (x,y) on the image and its corresponding quantization response value is called a pixel.

Image representation

Two-dimensional matrix is an important digital form of digital image. An M*N image can be represented as a matrix, and each element in the matrix is called the pixel of the image. Each pixel has its own spatial position and value, which is the color or intensity of the pixel at that position. The important index related to image is image resolution. Image resolution refers to the density of pixels that make up an image. For an image of the same size, the more pixels that constitute the image, the higher the resolution of the image, the more realistic it looks. Conversely, the fewer pixels, the coarser the image. Image resolution includes spatial resolution and gray level (response amplitude) resolution. Spatial resolution is the minimum discernible spatial detail in the image, and the sampling value is the main parameter to determine the spatial resolution of the image.

read

skimage

from skimage import io,data,color from matplotlib import pyplot as plt img=io.imread('123.jpg') img1=data.astronaut() Img0 = IO. Imread ('123.jpg',as_gray=True) print(" img: ",type(img)) ",img.shape) print(img.shape[0]) print(img.shape[1]) print(img.shape[2]) print(img.size) print(img.max()) print(img.min()) print(img.mean()) print(img[0][0]) plt.subplot(211),io.imshow(img) plt.title('Input Image'),plt.xticks([]),plt.yticks([]) plt.subplot(212),io.imshow(img0) plt.show()Copy the code

opencv

Import cv2 as CV. Imread ('123.jpg') print(" img: ",type(img)) ",img.shape) print(img.shape[0]) print(img.shape[1]) print(img.shape[2]) print(img.size) print(img.max()) print(img.min()) print(img.mean()) print(img[0][0]) img1=cv.imread('123.jpg',0) cv.imshow('Color',img) cv.imshow('gray',img1) cv.waitKey(0) cv.destroyAllWindows()Copy the code

Color channel operation

from skimage import io,data,color from matplotlib import pyplot as plt image=io.imread('123.jpg') image_r=image[:,:,0] Image_g =image[:,:,1] image_b=image[:,:,2] plt.imshow (image) plt.subplot(2,2,2) io.imshow(image_r) Imshow (image_g) plt.subplot(2,2,4) io.imshow(image_b) plt.show()Copy the code

Prepare a digital image reading, display, region cutting procedures, and respectively display R, G, B three channels of the image

from PIL import Image import matplotlib.pyplot as plt from skimage import io img2 = io.imread('456.jpg') img = Gray = img.convert('L') # convert to gray r, g, b = img.split() # split image.merge ('RGB', Figure ("beauty") plt.subplot(3, 3, 1), plt.title('origin') plt.imshow(img), Plt. axis('off') # image cutoff img3 = img2[20:400, 50:1000] plt.figure("beauty") plt.subplot(3, 3, 7) plt.title('caijian') plt.imshow(img3), plt.axis('off') plt.subplot(3, 3, 4), plt.title('r') plt.imshow(r, cmap='gray'), plt.axis('off') plt.subplot(3, 3, 5), plt.title('g') plt.imshow(g, cmap='gray'), plt.axis('off') plt.subplot(3, 3, 6), plt.title('b') plt.imshow(b, cmap='gray'), plt.axis('off') plt.show()Copy the code

subsequent

If you like, just watch it

Writing is not easy, thank you for your support.

This article uses the article synchronization assistant to synchronize