• Python numpy implementation of gray image segmentation and merging


    I don’t want to talk much nonsense. Let’s go straight to the code! from numpy import * import numpy as np import cv2, os, math, os.path from PIL import Image base=”F:\\Spy_CNN\\pythonCode\\cvSPY\\cvTest\\LBP\\LBPImag3\\” base2=”F:\\ProgrameCode\\FaceDataLib\\orl_Arry\\” imageOld=cv2.imread(base2+”s1_1.bmp”) image=cv2.cvtColor(imageOld,cv2.COLOR_BGR2GRAY) Synthesis of image H,W=image.shape#(112, 92) kuai=5 A = 1 # in order to adjust the program maskx,masky = H/kuai,W/kuai  #29 14 […]

  • The calculation method of NDVI by Python & & GDAL


    A few short sentences of code, but it took me a long time to write them, because the division result of array is always wrong, which is normally between – 1-1. From other data to deal with the array code of NDVI calculation, there are a lot of problems. Maybe it uses some optimized calculation […]

  • Example of conversion between Python PIL / CV2 / Base64


    PIL and CV2 are two commonly used image processing libraries in Python. PIL is usually provided by anaconda, and CV2 is the python version of OpenCV. Base64 is often used when transmitting pictures on the network. ##PIL method of reading and saving pictures from PIL import Image img = Image.open(img_path) img.save(img_path2) ##Methods of reading and […]

  • Python to achieve opencv used by the image format and Base64 conversion


    The NP image (imread image) is transcoded to Base64 format def image_to_base64(image_np): image = cv2.imencode(‘.jpg’,image_np)[1] image_code = str(base64.b64encode(image))[2:-1] return image_code Parsing Base64 encoding into opencv available pictures def base64_to_image(base64_code): #Base64 decoding img_data = base64.b64decode(base64_code) #Convert to NP array img_array = np.fromstring(img_data, np.uint8) #Convert to opencv format img = cv2.imdecode(img_array, cv2.COLOR_RGB2BGR) return img The above image […]

  • Python implementation of I personnel automatic clock out sample code


    The punch in software used by our company is I personnel. However, I often miss the punch in and check out. I will forget when I set the alarm clock. Today, I was defeated by the boss again. So we are ready to grasp the check-in interface and use crontab to realize automatic check-in and […]

  • Implementation of OpenCV format and pil.image format conversion with Python


    OpenCV to pil.image format: import cv2 from PIL import Image import numpy img = cv2.imread(“plane.jpg”) cv2.imshow(“OpenCV”,img) image = Image.fromarray(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) image.show() cv2.waitKey() Pil.image to opencv format: import cv2 from PIL import Image import numpy image = Image.open(“plane.jpg”) image.show() img = cv2.cvtColor(numpy.asarray(image),cv2.COLOR_RGB2BGR) cv2.imshow(“OpenCV”,img) cv2.waitKey() The above Python implementation of OpenCV format and PIL. Image format conversion is […]

  • Python + opencv implementation of rotating text correction


    Suppose we have an image in which the text is rotated at an unknown angle. In order to correct the angle of the text, we need to complete the following steps: 1. Detect the text range in the graph 2. Calculate the angle at which the text is rotated 3. Rotate the image at a […]

  • Python variables, data types, data type conversion related function usage examples


    In this paper, examples about Python variables, data types, data type conversion function usage. The details are as follows: The use of Python variables does not require type declaration (type name, variable name). The value assigned to a variable name is the type. Variable assignment and use= Note: Although Python does not have a type […]

  • Python decodes Base64 to get code stream format text instance


    I don’t want to talk much nonsense. Let’s go straight to the code! # coding:utf8 import base64 def BaseToFlow(): while True: str = input(“Please input src: “) flag = input(“Please input Decode – 1 or Encode – 2: “) if str == “”: str = “ApIAGBcEAAAEBO6x3nLykEEhjWMX1wHs” if flag == “”: flag = “1” if flag […]

  • Python turns the picture to Base64 to realize the front-end display


    As follows: # -*- coding: utf-8 -*- import base64 with open(“C:\\Users\\user\\Desktop\\20170508134213.png”,”rb”) as f: #B64encode is encoding and b64decode is decoding base64_data = base64.b64encode(f.read()) # base64.b64decode(base64data) print(base64_data) result: It’s too long to show all How to call Base64 directly in front-end HTML? use <img src=” data:image/jpg; Base64, here is the code of Base64 It’s too long […]

  • Analysis of Python annotation, branch structure, loop structure and pseudo selection structure


    In this paper, examples of Python comments, branch structure, loop structure, pseudo “select structure” usage. The details are as follows: notes: Python uses # as the line annotator and three quotation marks as the multiline annotator Branch structure: if-else: A = int (input (“your score is:)) if a>60: Print (“you’re qualified!”) else : Print (“you […]

  • Python implementation of flash in the return of image stream to the front-end display


    Scenario requirements:You need to find a picture in the local flash server and return it to the front end for display. Questions:Usually, the front-end < img > tag will only accept the form of URL to display the image, and never try to return a local image of the server to the front-end. So write […]