[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1753526910508623.png (43 KB, 1487x645)
43 KB
43 KB PNG
Post your best Python scripts.
#!/usr/bin/env python3

import cv2

import os
import random
import sys
import time

if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: {} image (n)".format(sys.argv[0]))
sys.exit(1)
fn = sys.argv[1]

n = 1
if len(sys.argv) > 2:
n = int(sys.argv[2])

dir = os.path.split(fn)[0]
ext = os.path.splitext(fn)[-1]
im_orig = cv2.imread(fn, cv2.IMREAD_UNCHANGED)
for i in range(n):
im = im_orig.copy()
x = random.randint(0, im.shape[1]-1)
y = random.randint(0, im.shape[0]-1)
im[y, x] += 1

name = f"{int(time.time()*1000+i)}{ext}"
cv2.imwrite(os.path.join(dir, name), im)

>>
>>106429956
Snek language xDDD
>>
ai datamine thread
>>
Good morning saar
>>
python, i am reading about perl.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.