導航:首頁 > 編程語言 > 用python如何令圖形旋轉

用python如何令圖形旋轉

發布時間:2022-06-16 05:15:22

python里如何將視頻旋轉

好象調用一次主窗口的close似乎就可以。或者是app的close, 或者是destroy或者是terminate,不記得是哪個函數了。 當然你殺掉自己也是可以的。 用kill。 或者是sys.exit也應該可以。

⑵ python做三維圖結果怎麼用滑鼠拖動旋轉

旋轉視角,要根據三角函數計算的,每轉動一個角度都需要重新計算,這些都需要實現,之後根據轉動的數值傳入進去,計算後,重新畫圖

⑶ 如何用Python+Pygame旋轉圖像、灰度圖像

『』『
2013-7-4
by JavenLee
希望能帶給你啟發
'''
import Image
img = Image.open(『origin.png』) # 得到一個圖像的實例對象 img
rot_img = img.rotate(270) #順時針旋轉90度
rot_img.save("rot_img.jpg")
x_img=img.transpose(Image.FLIP_LEFT_RIGHT) #垂直翻轉
y_img=img.transpose(Image.FLIP_TOP_BOTTOM) #水平翻轉

new_imag=img.convert('L')
'''
模式
img.convert() 參數說明如下:
1 1位像素,黑和白,存成8位的像素
L 8位像素,黑白
P 8位像素,使用調色板映射到任何其他模式
RGB 3×8位像素,真彩
RGBA 4×8位像素,真彩+透明通道
CMYK 4×8位像素,顏色隔離
YCbCr 3×8位像素,彩色視頻格式
I 32位整型像素
F 32位浮點型像素

'''

⑷ 如何用python繪制各種圖形

1.環境

系統:windows10

python版本:python3.6.1

使用的庫:matplotlib,numpy

2.numpy庫產生隨機數幾種方法

import numpy as np
numpy.random

rand(d0,d1,...,dn)

In [2]: x=np.random.rand(2,5)

In [3]: x
Out[3]:
array([[ 0.84286554, 0.50007593, 0.66500549, 0.97387807, 0.03993009],
[ 0.46391661, 0.50717355, 0.21527461, 0.92692517, 0.2567891 ]])

randn(d0,d1,...,dn)查詢結果為標准正態分布

In [4]: x=np.random.randn(2,5)

In [5]: x
Out[5]:
array([[-0.77195196, 0.26651203, -0.35045793, -0.0210377 , 0.89749635],
[-0.20229338, 1.44852833, -0.10858996, -1.65034606, -0.39793635]])

randint(low,high,size)

生成low到high之間(半開區間 [low, high)),size個數據

In [6]: x=np.random.randint(1,8,4)

In [7]: x
Out[7]: array([4, 4, 2, 7])

random_integers(low,high,size)

生成low到high之間(閉區間 [low, high)),size個數據

In [10]: x=np.random.random_integers(2,10,5)

In [11]: x
Out[11]: array([7, 4, 5, 4, 2])

3.散點圖

x x軸
y y軸
s 圓點面積
c 顏色
marker 圓點形狀
alpha 圓點透明度#其他圖也類似這種配置
N=50# height=np.random.randint(150,180,20)# weight=np.random.randint(80,150,20)
x=np.random.randn(N)
y=np.random.randn(N)
plt.scatter(x,y,s=50,c='r',marker='o',alpha=0.5)
plt.show()

8.箱型圖

import matplotlib.pyplot as pltimport numpy as npdata=np.random.normal(loc=0,scale=1,size=1000)#sym 點的形狀,whis虛線的長度plt.boxplot(data,sym="o",whis=1.5)plt.show()
#sym 點的形狀,whis虛線的長度

⑸ python 圖像旋轉怎麼去除黑邊

去除黑邊現象的辦法:
1)在做圖像坐標映射反查的時候,算出當前點在原始圖像的外部還是內部,若在外部,判斷當前像素點的X或者Y位置,找臨近四個邊界的像
素值代替;

該方法太過繁瑣,適合自己寫程序實現,如若想調用現有的一些庫函數,可以考慮2)做法:

2)將待旋轉的圖像進行邊界填充,最不濟的情況下可以擴充為原始圖像的大小;

旋轉邊界填充圖像;

計算原始圖像經過旋轉以後的結果圖像的尺寸大小;

在邊界填充旋轉圖像上截取目標圖像;(圖像都是按照圖像中心旋轉的);
附上一段matlab人臉根據人眼位置對齊的代碼:
[plain] view plain
eye_angle = atan2( (eye_pts(2,2) - eye_pts(1,2)),(eye_pts(2,1) - eye_pts(1,1) ) ) * 180 / pi; % 人眼的傾斜角度
if eye_angle < 0
eye_angle = eye_angle + 360;
end
if floor(eye_angle) <= 5 || floor( 360 - eye_angle ) <= 5
continue;
end % 5度之內不做對齊操作
img = imread(img_path);
[m,n,~] = size(img);
img_pad = padarray(img,[m n],'both','replicate');% 擴充圖像
img_pad_rotate = imrotate(img_pad,eye_angle,'bilinear'); % 旋轉擴充圖像
[m_pad_r,n_pad_r,~] = size(img_pad_rotate);
[plain] view plain
eye_angle = eye_angle * pi / 180;
f_cos = cos(eye_angle);f_sin = sin(eye_angle);
new_m = floor(m * abs(f_cos) + n * abs(f_sin));
new_n = floor(n * abs(f_sin) + m * abs(f_cos));% 最終對齊圖像的大小
left = floor((n_pad_r - new_n) / 2);right = left + new_n;
bott = floor((m_pad_r - new_m) / 2);up = bott + new_m;
face_rorate = img_pad_rotate(bott : up,left : right,:); % 截取目標圖像
figure,imshow(face_rorate)

⑹ J在windowes上對圖片進行右鍵旋轉後,在Python語言中對img 使用size()方法,獲取的寬高仍為旋轉之前的!

只有相應顯示文字信息沒變,但圖片視覺效果和windows旋轉的一樣嗎

⑺ 如何旋轉一個多邊形在python的Tkinter的畫布

這個跟編碼方式有關, 加上#-*- coding: utf8 -*- 就能顯示中文啦 self.Button(self.trspt_frm, \ text='發送文件', \ command=self.send_file, \ ).pack(side=Tkinter.LEFT, fill=Tkinter.BOTH) 在pack里設置參數,就可以設置按鈕的位置啦

⑻ 怎麼樣在python中讓最後畫出來的圖翻轉90度

importImage
importos
importglob

dir="f:mobile"
#取出指定文件
file=glob.glob(os.path.join(dir,'xxx.JPG'))

#打開圖片
img=Image.open(file)

#顯示圖片
img.show()
printimg.format,img.size,img.mode
print"rotatingimage....."
im=img.rotate(90)
im.save(image)

我不知道你怎麼畫的,但旋轉請參考以上代碼

⑼ python能用滑鼠旋轉散點圖嗎

首先,你需要用到python的圖形用戶界面的模塊 其次,你需要用到裡面繪制界面和添加滑鼠響應的功能模塊

⑽ 用python做一個地球圍繞太陽轉的圖形

平台: python2.7.10 + wxpython 3.0.2

#!/usr/bin/env python
#-*- coding: utf-8 -*-

from __future__ import unicode_literals
import wx

__version__ = '0.1'
app_title = 'Temperature Translator - {}'.format(__version__)

class TempTranslator(wx.Frame):
def __init__(self, parent=None, size=(620, 200), title=app_title):
super(TempTranslator, self).__init__(parent, size=size, title=title)
self.SetMinSize(self.GetSize())
self.panel = wx.Panel(self)

self.init_layout()
self.panel.Layout()
self.Centre(wx.BOTH)
self.Show()

def init_layout(self):
font = self.GetFont()
font.SetWeight(wx.BOLD)
font.SetPointSize(15)
self.panel.SetFont(font)

vbox = wx.BoxSizer(wx.VERTICAL)
self.add_label(vbox, f2c=True)
self.f_tc1, self.c_tc1 = self.add_input(vbox, f2c=True)
self.f_tc1.Bind(wx.EVT_TEXT, self.on_f_text)

line = wx.StaticLine(self.panel, -1, style=wx.LI_HORIZONTAL)
style = wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP
vbox.Add(line, 0, style, 5)

self.add_label(vbox, f2c=False)
self.c_tc2, self.f_tc2 = self.add_input(vbox, f2c=False)
self.c_tc2.Bind(wx.EVT_TEXT, self.on_c_text)

self.panel.SetSizer(vbox)

def add_label(self, vbox, f2c=True):
if f2c:
text1 = 'Fahrenheit'
text2 = 'Celsius'
else:
text1 = 'Celsius'
text2 = 'Fahrenheit'

hbox = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self.panel, -1, text1, size=(-1, 30),
style=wx.ALIGN_CENTER)
hbox.Add(label, 1, wx.EXPAND, 10)

label = wx.StaticText(self.panel, -1, text2, size=(-1, 30),
style=wx.ALIGN_CENTER)
hbox.Add(label, 1, wx.EXPAND, 10)
vbox.Add(hbox, 0, wx.EXPAND, 10)

def add_input(self, vbox, f2c=True):
hbox = wx.BoxSizer(wx.HORIZONTAL)
tc1 = wx.TextCtrl(self.panel, -1, size=(260, 40), style=wx.TE_CENTER)
tc1.Bind(wx.EVT_TEXT, self.on_f_text)

label = wx.StaticText(self.panel, -1, ' = ')

tc2 = wx.TextCtrl(self.panel, -1, size=(260, 40), style=wx.TE_CENTER)

hbox.Add(tc1, 1, wx.EXPAND, 10)
hbox.Add(label, 0, wx.ALL | wx.EXPAND, 10)
hbox.Add(tc2, 1, wx.EXPAND, 10)
vbox.Add(hbox, 1, wx.EXPAND, 10)
return tc1, tc2

def on_f_text(self, evt):
f = self.f_tc1.GetValue()
self.c_tc1.SetValue('{}'.format(self.f2c(f)))

def on_c_text(self, evt):
c = self.c_tc2.GetValue()
self.f_tc2.SetValue('{}'.format(self.c2f(c)))

def f2c(self, f):
return (float(f) - 32) / 1.8 if f else ''

def c2f(self, c):
return float(c) * 1.8 + 32 if c else ''

if __name__ == '__main__':
app = wx.App()
TempTranslator()
app.MainLoop()

閱讀全文

與用python如何令圖形旋轉相關的資料

熱點內容
30歲學編程晚嗎 瀏覽:68
解壓專家怎麼打開 瀏覽:86
php開源留言板 瀏覽:49
新鄉市區疫情怎麼查詢app 瀏覽:158
我的世界伺服器怎麼弄圖 瀏覽:999
vc6的編譯框 瀏覽:198
程序員寫照 瀏覽:539
怎麼退出github伺服器版本 瀏覽:797
雲伺服器sip 瀏覽:910
對稱平衡型壓縮機 瀏覽:953
rust連接什麼伺服器 瀏覽:382
php刪除數組的空元素 瀏覽:74
有什麼古今翻譯的app 瀏覽:54
華為平板里的app熱門推薦怎麼關閉 瀏覽:731
kindle可以看pdf嗎 瀏覽:620
小米文件夾變小 瀏覽:324
為什麼安卓系統不設計橫屏 瀏覽:686
myeclipse編譯文件 瀏覽:586
水果解壓視頻教程 瀏覽:207
單片機控制的大一點的車 瀏覽:640