각종resize
10145 단어 기계 학습
opencv
resize(src, dsize, dst, fx, fy, interpolation)
그 중에서 dsize와 fx&fy 둘 중 하나를 선택하면 됩니다. dsize는 (width,height) 모드이고 interpolation은 삽입 방식이며 기본값은INTER 입니다.LINEAR
코드
보간법
INTER_NEAREST
최근 인접 보간(빠르지만 앤티앨리어싱)
INTER_LINEAR
이중 보간(기본값, 빠른 속도, 괜찮은 효과)
INTER_AREA
픽셀 영역 관계를 사용하여 재샘플링(이미지 축소 권장)
INTER_CUBIC
4x4 픽셀 인접 영역의 더블 세 번 삽입값 (속도가 느리고 효과가 좋다)
INTER_LANCZOS4
8x8 픽셀 인접 영역에 대한 Lanczos 보간
img = cv2.imread('test.jpg')
height, width = img.shape[:2] #shape (height, width, channel)
img_resize = cv2.resize(img, (width / 2, height / 2), interpolation=cv2.INTER_NEAREST) #dsize (width, height)
img_resize = cv2.resize(img, (0, 0), None, fx=0.5, fy=0.5)
#include
#include
cv::Mat img = cv::imread("test.jpg", 1);
cv::Mat img_resize;
cv::resize(img, img_resize, cv::Size(200, 100), 0, 0, cv::INTER_LINEAR);
PIL
축소 방식은NEAREST,BOX,BILINEAR,HAMMING,BICUBIC,LANCZOS,기본값은NEAREST,size모드는(width,height)
import PIL.Image as Image
img = Image.open('test.jpg')
height, width = img.height, img.width
img_resize = img.resize((width / 2, height / 2), Image.BILINEAR)
Keras
size의 모드는 (height,width)이고 PIL의resize 방법을 사용합니다
image_size = (image_height, image_width)
train_datagen = ImageDataGenerator(rescale=1.0/255)
train_generator = train_datagen.flow_from_directory(
'datasets/mytrain', # this is the target directory
target_size=image_size, # all images will be resized to 224x224
batch_size=16,
class_mode='binary')
Tensorflow
tf.image.resize_images(
images,
size,
method=ResizeMethod.BILINEAR,
align_corners=False
)
size의 모드는 (height,width)입니다. 삽입 방식은 다음과 같습니다. Resize Method.BILINEAR: 이중 보간(기본값) ResizeMethod.NEAREST_NEIGHBOR: 가장 가까운 이웃 삽입값.ResizeMethod.BICUBIC: 더블 세 번 삽입값.ResizeMethod.AREA: 영역 보간.
img_raw = cv2.imread('test.jpg')
h, w, _ = img_in.shape
tf_img_in = tf.placeholder(dtype=tf.float32, shape=(None, None, 3))
scale = 0.5
tf_img_op1 = tf.image.resize_images(tf_img_in, [h * scale, w * scale], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR) # tensor
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
형태소 분석은 데스크톱을 구성하는 데 도움이?문자×기계 학습에 흥미를 가져와 개인 범위의 용도를 생각해, 폴더 정리에 사용할 수 있을까 생각해 검토를 시작했습니다. 이번 검토에서는 폴더 구성 & text의 읽기 → mecab × wordcloud를 실시하고 있...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.