Skip to content

Instantly share code, notes, and snippets.

View MiyabiTane's full-sized avatar

Miyabi Tanemoto MiyabiTane

  • Tokyo, Japan
View GitHub Profile
@MiyabiTane
MiyabiTane / change_json_look.py
Last active April 26, 2021 09:26
jsonファイルを見やすくする
import json
import sys
file_name = sys.argv[1]
json_open = open(file_name, 'r')
json_load = json.load(json_open)
json_write = open("output" + file_name, 'w')
json.dump(json_load, json_write, ensure_ascii=False, indent=4, sort_keys=True, separators=(',', ': '))
@MiyabiTane
MiyabiTane / image_synthesis.py
Created November 9, 2020 05:56
RGB画像とマスク画像をずらして合成する
import cv2
import numpy as np
def image_syn(rgb_img_path, mask_img_path, output_path, x_move, y_move):
# two image -> same size (3D H,W,C=3)
cv_image = cv2.imread(rgb_img_path)
mask_image = cv2.imread(mask_img_path)
img_gray = cv2.cvtColor(mask_image, cv2.COLOR_BGR2GRAY)
_thre, bw_img = cv2.threshold(img_gray, 1, 255, cv2.THRESH_BINARY)
rows,cols = bw_img.shape
@MiyabiTane
MiyabiTane / cache_using_list_and_dict.py
Created May 27, 2020 09:46
STEP Week2 homework4 no.2
import sys
# Cache is a data structure that stores the most recently accessed N pages.
# See the below test cases to see how it should work.
#
# Note: Please do not use a library (e.g., collections.OrderedDict).
# Implement the data structure yourself.
class Cache:
@MiyabiTane
MiyabiTane / cache_doubly-linked-list.py
Last active June 1, 2020 14:23
STEP Week2 homework4 no.1
import sys
# Cache is a data structure that stores the most recently accessed N pages.
# See the below test cases to see how it should work.
#
# Note: Please do not use a library (e.g., collections.OrderedDict).
# Implement the data structure yourself.
class Node:
def __init__(self, url, contents):
@MiyabiTane
MiyabiTane / calc_mat_mal_time.py
Created May 27, 2020 09:43
STEP Week2 homework1
import numpy, sys, time
if (len(sys.argv) != 2):
print("usage: python %s N" % sys.argv[0])
quit()
n = int(sys.argv[1])
a = numpy.zeros((n, n)) # Matrix A
b = numpy.zeros((n, n)) # Matrix B
c = numpy.zeros((n, n)) # Matrix C