光的世界︰派生科學計算八

仲夏入園中東陂‧唐‧儲光羲

方塘深且廣,伊昔俯吾廬。
環岸垂綠柳,盈澤發紅蕖。
上延北原秀,下屬幽人居。
暑雨若混沌,清明如空虛。
此鄉多隱逸,水陸見樵漁。
廢賞亦何貴,為歡良易攄。
且言重觀國,當此賦歸歟。

 

欲究 skimage 相似變換之理︰

SimilarityTransform

class skimage.transform.SimilarityTransform(matrix=None, scale=None, rotation=None, translation=None)

Bases: skimage.transform._geometric.EuclideanTransform

2D similarity transformation of the form:

X = a0 * x – b0 * y + a1 =
= s * x * cos(rotation) – s * y * sin(rotation) + a1
Y = b0 * x + a0 * y + b1 =
= s * x * sin(rotation) + s * y * cos(rotation) + b1

where s is a scale factor and the homogeneous transformation matrix is:

[[a0  b0  a1]
 [b0  a0  b1]
 [0   0    1]]

The similarity transformation extends the Euclidean transformation with a single scaling factor in addition to the rotation and translation parameters.

Parameters:

matrix : (3, 3) array, optional

Homogeneous transformation matrix.

scale : float, optional

Scale factor.

rotation : float, optional

Rotation angle in counter-clockwise direction as radians.

translation : (tx, ty) as array, list or tuple, optional

x, y translation parameters.

Attributes

params ((3, 3) array) Homogeneous transformation matrix.

 

,如墜混沌中,莫非是因暑雨後,頭昏腦不清!這 X 何指?那 Y 又是什麼 □ ○ ??考之 draw 模組圓盤和線段之說明︰

circle

skimage.draw.circle(r, c, radius, shape=None)
Generate coordinates of pixels within circle.

Parameters:

r, c : double

Centre coordinate of circle.

radius : double

Radius of circle.

shape : tuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for circles which exceed the image size. By default the full extent of the circle are used.

Returns:

rr, cc : ndarray of int

Pixel coordinates of circle. May be used to directly index into an array, e.g. img[rr, cc] = 1.

Notes

This function is a wrapper for skimage.draw.ellipse()

……

line

skimage.draw.line()
Generate line pixel coordinates.

Parameters:

y0, x0 : int

Starting position (row, column).

y1, x1 : int

End position (row, column).

Returns:

rr, cc : (N,) ndarray of int

Indices of pixels that belong to the line. May be used to directly index into an array, e.g. img[rr, cc] = 1.

See also

line_aa
Anti-aliased line generator

 

明示『列』 row 與『行』 column !!yx 之前,難道是講︰(r,  c) = (y,  x) 耶??既然無由計,方塘深且廣,怎不直搗黃龍,親驗座標系乎!!且以笛卡爾座標系── 橫平 x  、豎直 y ,右手逆旋角度為正,左手順轉角度為負 ── 考察一番︰

pi@raspberrypi:~ ipython3 Python 3.4.2 (default, Oct 19 2014, 13:31:11)  Type "copyright", "credits" or "license" for more information.  IPython 2.3.0 -- An enhanced Interactive Python. ?         -> Introduction and overview of IPython's features. %quickref -> Quick reference. help      -> Python's own help system. object?   -> Details about 'object', use 'object??' for extra details.  In [1]: import numpy as np  In [2]: import matplotlib.pyplot as plt  In [3]: from skimage.transform import warp, SimilarityTransform  In [4]: from skimage.draw import circle, line  In [5]: 圓 = lambda r,c: (r - 100)**2 + (c - 200)**2 <= 100  In [6]: 圖像 = np.fromfunction(圓, (512,512))  In [7]: 圖像[line(100,200,150,300)] = True  In [8]: plt.gray()  In [9]: plt.imshow(圖像) Out[9]: <matplotlib.image.AxesImage at 0x706e2ef0>  In [10]: plt.show()  In [11]: y平移 = SimilarityTransform(scale=1, rotation=0,translation=(0, 50))  In [12]: y平移圖 = warp(圖像, y平移.inverse)  In [13]: y平移圖[circle(100,200,10)] = True  In [14]: y平移圖[line(100,200,150,300)] = True  In [15]: plt.imshow(y平移圖) Out[15]: <matplotlib.image.AxesImage at 0x718b5290>  In [16]: plt.show()  In [17]: x平移 = SimilarityTransform(scale=1, rotation=0,translation=(50, 0))  In [18]: x平移圖 = warp(圖像, x平移.inverse)  In [19]: x平移圖[circle(100,200,10)] = True  In [20]: x平移圖[line(100,200,150,300)] = True  In [21]: plt.imshow(x平移圖) Out[21]: <matplotlib.image.AxesImage at 0x6fe4dd50>  In [22]: plt.show()  In [23]: 逆旋轉 = SimilarityTransform(scale=1, rotation=3.14159/18,translation=(0, 0))  In [24]: 逆旋轉圖 =  warp(圖像, 逆旋轉.inverse)  In [25]: 逆旋轉圖[circle(100,200,10)] = True  In [26]: 逆旋轉圖[line(100,200,150,300)] = True  In [27]: plt.imshow(逆旋轉圖) Out[27]: <matplotlib.image.AxesImage at 0x6f811770>  In [28]: plt.show()  In [29]: 順旋轉 = SimilarityTransform(scale=1, rotation=-3.14159/18,translation=(0, 0))  In [30]: 順旋轉圖 =  warp(圖像, 順旋轉.inverse)  In [31]: 順旋轉圖[circle(100,200,10)] = True  In [32]: 順旋轉圖[line(100,200,150,300)] = True  In [33]: plt.imshow(順旋轉圖) Out[33]: <matplotlib.image.AxesImage at 0x6f6a0170>  In [34]: plt.show()  In [35]:  </pre>    <span style="color: #808080;">【圖像】</span>  <img class="alignnone size-full wp-image-56929" src="http://www.freesandal.org/wp-content/uploads/圖像.png" alt="圖像" width="652" height="553" />     <span style="color: #808080;">【y平移圖】</span>  <img class="alignnone size-full wp-image-56928" src="http://www.freesandal.org/wp-content/uploads/y平移圖.png" alt="y平移圖" width="652" height="553" />     <span style="color: #808080;">【x平移圖】</span>  <img class="alignnone size-full wp-image-56927" src="http://www.freesandal.org/wp-content/uploads/x平移圖.png" alt="x平移圖" width="652" height="553" />     <span style="color: #808080;">【逆旋轉圖】</span>  <img class="alignnone size-full wp-image-56930" src="http://www.freesandal.org/wp-content/uploads/逆旋轉圖.png" alt="逆旋轉圖" width="652" height="553" />     <span style="color: #808080;">【順旋轉圖】</span>  <img class="alignnone size-full wp-image-56931" src="http://www.freesandal.org/wp-content/uploads/順旋轉圖.png" alt="順旋轉圖" width="652" height="553" />     <span style="color: #003300;">果然是『列』、『行』為Y、X$ !!當真的呢鏡中定『右逆』、『左順』之轉向也!!為何這樣寫??只覺太忽悠??

金文大篆倏

金文大篆忽

倏的本意︰
狗因杖打疾速逃窜。

《説文解字》:倏,走也。从犬,攸聲。

忽之語源︰
未放在心上,不重视。

《説文解字》:忽,忘也。从心,勿聲。

220px-西山經-帝江.svg

盤古

風雲變色

山海經‧西次三經》:

又西三百五十里曰天山,多金玉,有青雄黃,英水出焉,而西南流注於湯谷。有神焉,其狀如黃囊,赤如丹火,六足四翼,渾敦無面目是識歌舞,實惟帝江也

莊子‧內篇‧應帝王》︰

南海之帝為倏,北海之帝為忽,中央之帝為混沌。
倏與忽時相與遇於混沌之地,混沌待之甚善。
倏與忽謀報混沌之德,曰:

人皆有七竅,以視聽食息,此獨無有,嘗試鑿之。

日鑿一竅,七日而混沌死。

不 知莊子是否在忽悠人的嗎?混沌和盤古有無關係的呢??

─── 摘自《混沌理論

 

總不會想教人將文件看清楚,不明白時請反覆實驗吧??!!其後偶讀

 

skimagelogo

A crash course on NumPy for images

……

Coordinate conventions

Because we represent images with numpy arrays, our coordinates must match accordingly. Two-dimensional (2D) grayscale images (such as camera above) are indexed by row and columns (abbreviated to either row, col or r, c), with the lowest element (0, 0) at the top- -left corner. In various parts of the library, you will also see rr and cc refer to lists of row and column coordinates. We distinguish this from (x, y), which commonly denote standard Cartesian coordinates, where x is the horizontal coordinate, y the vertical, and the origin is on the bottom right. (Matplotlib, for example, uses this convention.)

In the case of color (or multichannel) images, the last dimension contains the color information and is denoted channel or ch.

Finally, for 3D images, such as videos, magnetic resonance imaging (MRI) scans, or confocal microscopy, we refer to the leading dimension as plane, abbreviated as pln or p.

These conventions are summarized below:

Dimension name and order conventions in scikit-image
Image type coordinates
2D grayscale (row, col)
2D multichannel (eg. RGB) (row, col, ch)
3D grayscale (pln, row, col)
3D multichannel (pln, row, col, ch)

 

只能哈哈大笑,何得清明如空虛矣!!!