본문 바로가기

Python

how to read/save an image as bmp in python cv2.imread(parse_file_name_read(read_dir, countFrames))cv2.imwrite(parse_file_name_save(save_dir, countFrames), image) 더보기
How to resize an image : skimage library ** 파이썬 이미지 크기 변형하기 **In matlab, it is very easy to resize an image. However, in python, you need to know which library do I have to import before resizing. In python, skimage library supports resizing an image like matlab. Here is an example. Enjoy!from skimage.transform import resize import skimage.io as io img = io.imread(file_name) img_resize = resize(img, (target_height, target_width)) 더보기
how to put text message on images using opencv library on python ** 파이썬에서 opencv를 이용하여 이미지에 text를 삽입하는 방법!! ** See the following cold. cv2.putText(image, "Hello. world!!", bottomLeftOrigin, fontFace, fontScale, textcolor) . image : numpy array of size [img_height, img_width, img_depth] . "Hello. world!!" : This will be displayed. . bottomLeftOrigin : for example, if you set (10, 10), bottom left corner of "H" character will be placed at (10, 10). . fontFace :.. 더보기
How to show an image : skimage library In matlab, it is very easy to show an image. However, in python, you need to know which library do I have to import before plotting the graph. In python, skimage library supports showing an image like matlab. Here is an example. Enjoy! import skimage.io as io img = io.imread(file_name) io.imshow(img) io.show() 더보기
How to plot a graph : mathplotlib library In matlab, it is very easy to plot a graph. However, in python, you need to know which library do I have to import before plotting the graph. In python, mathplotlib library supports plotting a graph like matlab. Here is an example. Enjoy! import numpy as np import math import matplotlib.pyplot as plt x = range(0, 100) # x-axis (index) y = np.zeros(100) # y-axis (value) for i in range(0, 100): y[.. 더보기
[NYU depth] How to read NYU depth dataset in python NYU depth v2 dataset can be downloaded from http://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html They provide images and corresponding depth-map (aligned and in-painted) for training and testing. The data is stored in the format of mat. The following code shows how to read the images and corresponding depth-map in python. Enjoy. // CODES ////////////////////////////////////// import skimage.i.. 더보기
How to set anaconda python as default ** 우분투에서 아나콘다 파이썬을 기본 파이썬으로 설정 ** step1) open a terminal step2) edit bashrc file by typing$ gedit ~/.bashrc step3) add the following comment at the bottom of the file## ANACONDAexport PATH=/home/dooseop/anaconda3/bin:${PATH} step4) close the terminal and open again, and check $which python-> /home/username/anaconda3/bin/python 더보기
How to write values in csv files * 파이썬에서 csv 파일 쓰기 *** Assume you want to write numbers from 1 to 8 along the first column of a csv file; // CODE /////////////////////////// import csv fp = open('/home/test.csv','w') // csvWriter = csv.writer(fp, lineterminator = '\n') for i in range(1,9): csvWriter.writerow([i]) fp.close() 더보기
How to read values from csv files * 파이썬에서 csv파일 읽기 *** Assme you have test.csv file that stores some values; You can read the values in python using the following example code // CODE //////////////////////////////////// import tensorflow as tf import numpy as np import skimage.io as io import csv import os def get_csv_reader(filename, delimiter): reader = [] if not os.path.isfile(filename): print("No such file or directory!") e.. 더보기
[tensorflow] how to load and use the saved trained network in python ** tensorflow에서 미리 저장한 CNN로드하고 사용하기 **** See '[tensorflow] how to save trained network' first. // PSEUDO CODE ////////////////////////////////////////import tensorflow as tfimport something # save trained netnet_dir = 'path_to_saved_trained_network'image_path = 'path_to_input_images' with tf.Session() as sess: # Step1) Load graph from meta file (meta file contains the graph that I had defined be.. 더보기