python randomly intercepts an image of any size on a single image
As shown below:
''' Randomized Generation of Negative Samples in Machine Learning ''' import cv2 import random #Read the picture img=('') #h, w is the size of the image you want to capture h=80 w=80 count=1 while 1: # Randomize x,y. This is a pixel-by-pixel range generation. y = (1, 890) x = (1, 1480) # Random screenshots cropImg = img[(y):(y + h), (x):(x + w)] ('pic/' + str(count) + '.png', cropImg) count+=1 if count==2500: break
Above this python randomly on an image to intercept any size of the picture is all I share with you, I hope to give you a reference, and I hope you support me more.
Related articles
Python3.9.0 a1 install pygame error resolution process (summary)
This article introduces the Python3.9.0 a1 installation pygame error resolution of the whole process (summary), the text through the sample code is very detailed, for everyone's learning or work has a certain reference and learning value, the need for friends below with the editorial to learn together!2021-02-02Implementation of Parameter Packing and Unpacking in Python
In Python, packing and unpacking parameters is a way to operate, you can pack multiple parameters into a tuple or dictionary, or you can unpack a tuple or dictionary into multiple parameters, this article will introduce how to use the2023-09-09A summary of five Python implementations for solving for the greatest common divisor
Finding the greatest common divisor is a relatively common type of exercise, this article will provide you with five more common algorithms, are implemented in the Python language, interested partners can understand the2022-07-07django tutorial how to teach yourself
In this content, I have organized a tutorial on django learning process, want to self-study friends can read.2020-07-07python calls to the saf automation framework
Today, I'd like to share a python call to the STAF automation framework, with good reference value, I hope to help you. Together follow the editor over to see it2018-12-12Summary of influx+grafana custom python collection data and some pitfalls
Some of the data type is not correct will lead to no datapoint error, it is really crazy, this article is to summarize the collection of data kind of some of the pit, I hope you can benefit from it!2018-09-09How to use FFmpeg to compress video files losslessly
FFmpeg is the industry's famous open-source image video processing program, in many video editing software, image processing software, are used in the FFmpeg, as well as such as OBS guide software inside the use of the FFmpeg, FFmpeg is very powerful, not only video compression, this article describes the use of FFmpeg to lossless compression of video files, the operation of the method! This article describes how to use FFmpeg to lossless compression of video files, interested friends to look at it together!2023-12-12Explaining Containers in Python Collections
This article mainly introduces the Python container collections of relevant information to help you better understand and learn python, interested parties can learn about the2020-08-08Python set
set is an unordered and non-repeating set of elements. This article mainly introduces the Python set of commonly used functions, need friends can refer to the following2017-11-11Programmer's Eve with 30 lines of code to make Python incarnation of the confession of God
Turning to our traditional Chinese Valentine's Day Tanabata, today I will take you to appreciate the way to use Python confession, interested friends to follow the editor together to see it!2019-08-08