本文整理匯總了C#中Procedurality.Channel.offset方法的典型用法代碼示例。如果您正苦於以下問題:C# Channel.offset方法的具體用法?C# Channel.offset怎麽用?C# Channel.offset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Procedurality.Channel
的用法示例。
在下文中一共展示了Channel.offset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: fft
public Channel[] fft() {
if(!(width == height))
throw new Exception("square images only");
int size = width;
if(!(Utils.isPowerOf2(size)))
throw new Exception("size must be power of 2");
// convert channel to complex number array
float[] a = new float[size*size*2 + 1];
int n = 1;
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
a[n] = getPixel(x, y);
n += 2;
}
}
// perform fast fourier transform
fastFourierTransform(a, size, 1);
// convert complex number array to channels
n = 1;
Channel magnitude = new Channel(size, size);
Channel phase = new Channel(size, size);
float real, imag;
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
real = a[n++];
imag = a[n++];
magnitude.putPixel(x, y, (float)Math.Sqrt(real*real + imag*imag));
if (imag == 0 && real >= 0) {
phase.putPixel(x, y, (float)Math.PI/2f);
} else if (imag == 0 && real < 0) {
phase.putPixel(x, y, (float)Math.PI/-2f);
} else {
phase.putPixel(x, y, (float)Math.Atan(real/imag));
}
}
}
// return magnitude and phase channels
return new Channel[]{magnitude.offset(size>>1, size>>1), phase};
}