首 页 | 网页模板 | 教程 | 源码下载 | 书籍下载 | 图片素材 | 字体 | JAVA特效 | FLASH源码 | 软件 | 矢量 | 论坛 | 其它 |
设为主页
加入收藏
联系站长
平面设计 | 网页制作 | 程序编写 | 数 据 库 | 媒体动画 | 网络冲浪 | 服务器相关 |
当前在线
广告:P4服务器电信机房6999/年即送产权 | 疾风下载
透析Photoshop的极坐标滤镜
2005-10-13 0:06:36  作者:模板天下收集整理  来源:天极网 网友评论 0 条 论坛
  

  三、 极坐标滤镜的工作过程(直角坐标到极坐标)

  一般而言,位图图像中的任意一点(象素)可以用直角坐标(x,y)来表示。同样这个象素也可以由极坐标(r,a)来表示。极坐标滤镜的工作过程就是将基于直角坐标系的象素(x,y)经过极坐标映射(r,a)之后再由直角坐标(x’,y’)表示出来的过程。

      直角坐标和极坐标的互化公式如下:

          r = sqrt ( x * x + y * y )
          a = arctg ( y / x )
          x = r * cos ( a )
          y = r * sin ( a )

  下面是一段是模拟极坐标滤镜工作的伪代码。这个代码并不是我编写的,我也只是看懂而已,更详细的解释可以参考下面的:

  

以下是引用片段:

Filter: Polar Coordinates

Source: [HOLZ88:48-49], [CLAE97]

The idea for this geometric transformation came from [HOLZ88:48-49]. Surprise! Photoshop® has this one too, but I did not realize it until after I began work on this filter and did some investigation. The idea here is simple. Pretend that the pixels in our Cartesian-based image are actually polar coordinates and display them using the Cartesian system. That is, a pixel at coordinate (x,y) has a corresponding polar coordinate radius and angle (r,a), using the center of the image as the polar origin. Here, to find a value for the filtered image, we find (r,a), then use r = x, and a = y and plot the point in our Cartesian system. The conversion to polar coordinates from Cartesian, is based on geometry and trigonometry:

   radius = sqrt(x*x + y*y)
   angle = arctan(x / y)

Although not used in this filter, the conversion back to Cartesian is given by:

   x = radius * cos(angle)
   y = radius * sin (angle)

Using this method, not every coordinate location in the filtered image would have been plotted with a pixel value from the original image. To resolve this issue, we first set every pixel in the filtered image to white.

As mentioned, the idea is simple, but the implementation takes careful work of the manipulation of both coordinate systems working together in order to produce the correct result. The simple pseudocode is given below, however the actual implementation is a bit more confusing. Much of the success of the results is based on trail and error. The interested reader is referred to the FilterExplorer code.

   for every pixel in the filtered image do
   currentpixel.color(255); // set to white

   for every pixel in the original image do
   {
   // x and y are the coordinates of the currentpixel
   // the pixel in the center of the image x = 0, y = 0
      r = sqrt(x*x + y*y);
      a = atan(x/y);
      x = r * image_height / R;
      y = a * image_width / 6.2832;
      filterpixel.x = x;
      filterpixel.y = y;
   }

I once found on the Internet a digital artist who made some interesting compositions using this filter, so if used creatively, the effect is worth more than just its novelty.


Polar coordinates on original with superimposed grid




  (这是个国外的东西,站主利用C++模拟出了一些PS的滤镜的效果,而且提供源代码和源程序。)

  for every pixel in the original image do
  {
    // x和y是当前象素在直角坐标内的坐标。
    // 图像中心点的坐标为 x = 0, y = 0。
    // r 和 a 是象素的极坐标。其中角度a为弧度单位。
    r = sqrt ( x * x + y * y );
    a = atan2 ( y / x );
    // R取图像长和宽的最小值的一半。
    R= min[ image_width , image_height ] / 2
    // 新的x和y是经过极坐标滤镜变换之后,象素在直角坐标系中的新坐标。这个转换的目的,特别是R和6.2832(2pi)的选择,我认为是将转换后的图像限定到原画布大小之内的作用。同时这个步骤最终导致了图像的变形。
    x = r * image_height / R;
    y = a * image_width / 6.2832;
    filterpixel.x = x;
    filterpixel.y = y;
  }

  这仅仅是一段伪代码而已,真正的执行过程要复杂一些,如果继续深入下去就严重跑题了,所以深入的讨论还是请参见那个链接,自己去看吧。

      最后引用那个网站的一句话作为结束语。

  “If used creatively, the effect is worth more than just its novelty.”

共分5页  [1] [2] [3] [4] [5] 
>> 相关文章

关于网站 | 客服中心 | 服务条款 | 友情链接 | 广告联系 | 本站历程 | 网站导航

吉ICP备05000107号