久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

向圖像添加填充以使它們具有相同的形狀

Add padding to images to get them into the same shape(向圖像添加填充以使它們具有相同的形狀)
本文介紹了向圖像添加填充以使它們具有相同的形狀的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一組不同尺寸的圖片(45,50,3), (69,34,3), (34,98,3).我想為這些圖像添加填充,如下所示:

l have a set of images of different sizes (45,50,3), (69,34,3), (34,98,3). l want to add padding to these images as follows:

取整張圖片的最大寬度和長度,然后把圖片放在那個尺寸

Take the max width and length of the whole images then put the image in that size

import os
import glob
import cv2

input_path="/home/images"
os.chdir(indput_path)
images=glob.glob("*.png")
Length=[]
Width=[]
for img in images:
    img=cv2.imread(img)
    width,length=img.shape[0:2]
    Length.append(length)
    Width.append(width)
W=max(Width)
L=max(Length)

如何在 opencv 中添加填充以使所有圖像具有相同的大小?在示例中 l 給出的圖像將得到 (69,98,3)

How can l add padding in opencv so that all the images will have the same size? In the example l gave the images will get the shape of (69,98,3)

推薦答案

你可以使用:

image = cv2.copyMakeBorder(src, top, bottom, left, right, borderType)

src 是你的源圖片,topbottomleftright 是圖像周圍的填充.

Where src is your source image and top, bottom, left, right are the padding around the image.

您可以在 while 循環中使用 max(sizes) - 圖像的大小值來為每個圖像添加填充.邊框類型可以是以下之一:

You can use max(sizes) - size value of the image in a while loop to add the padding to each image. The bordertype can be one of these:

  • cv2.BORDER_CONSTANT
  • cv2.BORDER_REFLECT
  • cv2.BORDER_REFLECT_101
  • cv2.BORDER_DEFAULT
  • cv2.BORDER_REPLICATE
  • cv2.BORDER_WRAP

cv2.copyMakeBorder 教程

這篇關于向圖像添加填充以使它們具有相同的形狀的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 免费观看的av毛片的网站 | 欧美日韩综合一区 | 国产精品久久久久久久久久免费看 | 国产一区二区成人 | 91久久精品国产91久久 | 成人小视频在线观看 | 日韩视频在线一区 | 亚洲国产成人精品女人久久久 | 天天插天天操 | 日韩av一区二区在线观看 | 中文字幕第5页 | 国产精品美女久久久久aⅴ国产馆 | 欧美国产日韩一区二区三区 | 亚洲国产18 | 日韩成人免费av | 中文字幕在线观看一区二区 | 成人免费观看男女羞羞视频 | 国产亚洲精品久久久久动 | 免费av电影网站 | 深夜福利亚洲 | 日韩在线欧美 | 国产伦一区二区三区视频 | 欧洲高清转码区一二区 | 久久精品国产亚洲a | 99re视频| 中文在线一区二区 | 国产精品久久久久久久久久久久久 | 精品久久久久国产 | 黄色福利 | 人妖videosex高潮另类 | www.久草| 国产精品av久久久久久毛片 | 久久首页| 免费成人高清在线视频 | 奇米av | 中国一级大黄大片 | 天堂综合 | 午夜电影日韩 | 97国产精品视频人人做人人爱 | 做a网站 | 91 在线|