https://github.com/fcakyon/labelme2coco GitHub - fcakyon/labelme2coco: A lightweight package for converting your labelme annotations into COCO object detection format. A lightweight package for converting your labelme annotations into COCO object detection format. - GitHub - fcakyon/labelme2coco: A lightweight package for converting your labelme annotations into ... github.com json_load 함수나 save..
머신러닝
아래 코드는 input 이미지가 jpg형식일 때 적용 가능한 코드 from PIL import Image, ImageDraw, ImageFont # Open the image file image = Image.open('./input_image.jpg') # Create a drawing context for the image draw = ImageDraw.Draw(image, "RGBA") # Define the polygon points polygon_points = [(50, 50), (200, 50), (200, 200), (50, 200)] #polygon_points = [50, 50, 200, 50, 200, 200, 50, 200] # Define the fill color and tran..
# x, y, w, h ROI img = cv2.imread('test.jpg') cropped_img = img[y: y + h, x: x + w] 참고자료 : https://eehoeskrap.tistory.com/419
Github : https://github.com/yellowjs0304/PascalVOC2Yolo 코드는 데이터 디렉토리 안에 배치 ┌── Data Directory ├── images : Image set Directory ├── train : XML set Directory(for Train) ├── val : XML set Directory(for Validation) ├── test : XML set Directory(for Test) ├── images_filelist.txt : List of Image Pathes ├── train_filelist.txt : List of Train XML pathes ├── val_filelist.txt : List of Validation XML path..
1. ColorThief PIL, python을 기반으로 하고 있는 모듈로 특정 이미지 내 color palette를 추출하거나 대표 컬러를 추출할 수 있음. 설치 방법은 아래 PIP 명령어 참고 $pip install colorthief 사용법은 아래와 같다 ColorThief 설치 후, 이미지를 colorthief 객체에 넣어준다. get_color 함수와 get_palette함수로 원하는 컬러를 얻어온다. 각 함수에 대한 자세한 설명은 다음 링크를 참고하자. GitHub - fengsp/color-thief-py: Grabs the dominant color or a representative color palette from an image. Uses Python and Pillow Grabs t..
https://datacarpentry.org/image-processing/aio/index.html#rgb-colour-table-optional-not-included-in-timing Image Processing with Python As computer systems have become faster and more powerful, and cameras and other imaging systems have become commonplace in many other areas of life, the need has grown for researchers to be able to process and analyse image data. Considering the large volu datac..
edit distance 는 단순하게 두 문장 or 단어가 얼마나 다르냐를 평가하는 값으로 아래와 같이 nltk에서 제공하는 함수를 import하면 바로 사용할 수 있다. # 단순한 ED score >>> from nltk.metrics.distance import edit_distance >>> edit_distance("바나나", "가나나") # 가-바 -> 한 글자 차이 1 >>> edit_distance("바나나", "가나다") # 가-바, 나-다 -> 두 글자 차이 2 이 edit distance를 정규화(ICDAR2019 평가 방식 참고)해서 표현해주면 아래와 같다. norm_ED += 1 - edit_distance("바나나", "가나나") / max(len("바나나"), len("가나나")..
networkx는 python으로 Graph(Node-Edge)를 표현할 수 있는 대표적인 패키지다. NetworkX — NetworkX documentation NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. networkx.org 이쁘기는 GraphViz도 있는데 범용성으로 보면 networkx가 더 나은 것 같다.( 추후, networkx와 Graphviz를 함께 사용할 수 있는 방법도 정리하겠다.) networkx의 기본적인 사용법은 다른곳에서도 많이 정리해 뒀기 때문에 따로 깊이 다루지 않겠지만, 기본적으로..
import os import numpy as np from IPython.display import Image def get_files(path): files = os.listdir(path) img_path =[] gt_path = [] for file in files: if file.split(".")[-1] in ["jpg"]: img_path.append(path+"/"+file) gt_path.append(path+"/"+file.split(".")[0]+".txt") return img_path , gt_path def is_on_same_line(box_a, box_b, min_y_overlap_ratio=0.8): """Check if two boxes are on the same lin..
이미지 내 특정 색을 다른 색으로 변경하고 싶을 때 출처 : https://stackoverflow.com/questions/62648862/how-can-i-change-the-hue-of-a-certain-area-with-opencv-python How can I change the hue of a certain area with OpenCV-Python i want to edit the hsv value of a certain area The picture I want to change color of I to change all the purple parts of the image to green. Here is the result I made in an image editing software..
https://stackoverflow.com/questions/58349726/opencv-how-to-remove-text-from-background
png중 배경이 투명한 이미지를 jpg처럼 흰 배경을 추가한 후, 변환 PIL Image 활용 image = Image.open("test.png").convert("RGBA") new_image = Image.new("RGBA", image.size, "WHITE") new_image.paste(image, mask=image) new_image.convert("RGB").save("test.jpg") cv2 활용 import cv2 #load image with alpha channel. use IMREAD_UNCHANGED to ensure loading of alpha channel image = cv2.imread('your image', cv2.IMREAD_UNCHANGED) #make mas..
다음과 같이 문장이 있는 image가 존재할 때, 문장 안에 있는 space(띄어 쓰기)마다 단어를 잘라 저장하고 싶을 때. 차례대로 순서를 나열하자면, 1) 글자의 굵기를 늘린다. 2) 겹쳐진 글자를 하나의 단어 뭉치로 본다. 3) cv2의 Contour찾는 함수로 단어들을 찾아낸다. 4) boundingRect값으로 기존 이미지를 단어 단위로 잘라내기 +) cv2상 Contour 찾는거는 검은 배경에서 흰색 물건을 찾는거라 생각하면 간단 => 따라서, 찾고자 하는 글자를 흰색, 배경을 검게 해야 함 => 그렇기 때문에 배경이 없는 png는 곤란함 cv2만을 사용하지만 PIL은 내가 따로 사용하려고, plt는 jupyter notebook에서 확인하기 위해서 import했다. import cv2 imp..
https://076923.github.io/posts/Python-opencv-1/ Python OpenCV 강좌 : 제 1강 - OpenCV 설치 OpenCV 076923.github.io
PIL로 Image open했는데 자동으로 돌아가는 경우 나는 분명 정방향 이미지를 주었는데 로딩했을 때 지 멋대로 돌아가는 경우가 존재한다. 이는 보통 핸드폰으로 찍은 사진에서 EXIF 안에 방향 태그가 존재할 경우, 발생하는 문제로 보인다. https://github.com/python-pillow/Pillow/issues/4703#issuecomment-645219973 PIL.Image.open is rotating jpeg images · Issue #4703 · python-pillow/Pillow Hello, I am trying to load images with Image.open. However, the images are autorotated if they were jpg images..