본문 바로가기

image

Image Frustum to Global 3D # generate camera frustum h, w = self.cfg['image']['h'], self.cfg['image']['w'] n_cam, dim, downsampled_h, downsampled_w = feat.size() # Depth grid depth_grid = torch.arange(1, 65, 1, dtype=torch.float) depth_grid = depth_grid.view(-1, 1, 1).expand(-1, downsampled_h, downsampled_w) n_depth_slices = depth_grid.shape[0] # x and y grids x_grid = torch.linspace(0, w - 1, downsampled_w, dtype=torch.f.. 더보기
PIL.image 라이브러리 사용법 1. Image Open from PIL import Image img = Image.open('./test.png') 2. Image Show img.show() 3. Image Characteristic img.filename # './test.png' img.formate # 'JPEG' img.size # (400, 400) img.mode # 'RGB' img.width # 400 img.height # 400 4. 이미지 크기 변경 resize_img = img.resize((WIDTH, HEIGHT), Image.NEAREST) resize_img = img.resize((WIDTH, HEIGHT), Image.BILINEAR) resize_img = img.resize((WIDTH, HEI.. 더보기
Resize and crop images in a specific directory from tqdm import tqdm import logging import traceback import argparse from PIL import Image import matplotlib.pyplot as plt import cv2 import random from pathlib import Path from utils.functions import read_config, read_json from IPython.display import display def resize_and_crop_image(img, resize_dims, crop): img = img.resize(resize_dims, resample=Image.BILINEAR) img = img.crop(crop) return img.. 더보기
Fast JPEG image loading by TurboJPEG from turbojpeg import TurboJPEG # define class class TurboJpegLoader(): def __init__(self, suffix, resize=None, crop=None): super(TurboJpegLoader, self).__init__() self.suffix = suffix self.resize = resize self.crop = crop self.jpeg = TurboJPEG() def __call__(self, path): if (path.exists() is not True): sys.exit(f'[Error] {str(path)} does not exists!!') in_file = open(str(path), 'rb') bgr_array .. 더보기
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 put text message on images using opencv library on C ** C/C++에서 opencv로 영상에 text 글자 삽입하기 ** CvFont font; char buffer[64]; // cvInitFont(CvFont*, int fontFace, double Hscale, double Vscale, double Shear, int thickness, int lineType); cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0, 1.5, CV_AA); // display just character cvPutText(screenRGB, "Target Speed:", cvPoint(10, 80), &font, cvScalar(0, 0, 255, 0)); // display the value of the float va.. 더보기
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 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() 더보기
[tensorflow] How to read a bmp file and feed it into CNN ** BMP, JPG 등 이미지 파일 읽어서 feed_dict 형식으로 CNN 입력하기 ** Assume you trained a CNN which takes RGB image of size (height, width, channel) as an input. After loading the trained CNN graph from, you may want to feed a test image into the CNN and see the inference result. // CODE ///////////////////////////import tensorflow as tf import numpy as np import os import skimage.io as io from skimage import tr.. 더보기