xs =  ys =  files = glob.glob ("./ sisaku-tra/*") for i, f in enumerate (files): img = cv2.imread (f) gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY) ret, binary = cv2.threshold (gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) kernel = cv2.getStructuringElement (cv2.MORPH_ELLIPSE, (5, 5)) binary = cv2.dilate (binary, kernel) contours, hierarchy = cv2.findContours (binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) target_contour = max (contours, key = lambda x: cv2.contourArea (x)) area = cv2.contourArea (target_contour) retval = cv2.arcLength (target_contour, True) ratio = area/retval xs.append (ratio) hsv = cv2.cvtColor (img, cv2.COLOR_BGR2HSV) h, s, v = cv2.split (hsv) v = v [10<v] value = v [v<225] .mean () ys.append (value) plt.scatter (xs, ys, s = 10) for i, (x, y) in enumerate (zip (xs, ys)): plt.annotate (str (i), (x, y), size = 5) plt.savefig ('plt1.jpg') Code
The above code gives a scatter plot like below
The order and point numbers stored in the sisaku-tra file are different.
Why is this?
Thank you for everyone.
Answer # 1
The order of the files obtained by
glob.globis clear and nothing is guaranteed.
Whether or not the results are sorted depends on the file system.
glob --- Unix-style pathname pattern expansion — Python 3.8.0 documentation
You say it will behave differently depending on the environment, it will return in the proper order, but that's it.
I can't figure out the situation, for example"There is no guarantee that you will get a list of files in that order even if they are neatly arranged in Explorer". I think there is a misunderstanding around that.
- python - if you want to put a number directly in the argument of most_similar of gensim
- python - draw a specified number of straight lines at equal intervals
- how to write to count the number of specific elements of dictionary values in python3
- i want to display a one-dimensional vector from the number entered with the python keyboard to 0
- in python, i want to extract an array from a number reference
- i want to get duplicate data of python csv and its line number
- python 3x - i want to specify the number of packets sent and received with the raspberry pi ping command
- python 3x - i want to combine a large number of csv files in the line direction
- python - how to specify the number of sheets from video data and cut out into frames
- i counted the number of days elapsed with python
- csv 4 or more serial number exclusion python
- set python excel serial number to date and time
- python 3x - how to get the list number of docx analyzed by mammoth
- python - i want to return the team number when the name of the matching list and the name of the person in charge in the data fr
- python - i want to get the number of subscribers from the channel id i got from the form using youtubeapi in django and save it
- python - i want to get the number of high and low ratings for videos
- python ai lottery winning number prediction lottery 7
- python - i want to increase the acquisition speed and increase the number of times
- please tell me how to count the number of occurrences within the specified period of weekly or monthly with python!
- python - [django] i want to display the count number of child models
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- python 3x - typeerror: 'method' object is not subscriptable
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - unresolved reference comes out in kotlin