2 shunfurh shunfurh 于 2017.01.02 12:32 提问

Image Rotation

Description

These days, Hunk is developing a special software for 2D digital image rotation. Here, the input image is described in the coordinate system shown in Figure 1 where the leftmost pixel of the image lies on the y-axis and the bottommost pixel of the image lies on the x-axis. The output image is described in the coordinate system shown in Figure 2 where and the leftmost pixel of the image lies on the y-axis, the topmost pixel lies on the x-axis.

He considers the following:

Each image is a rectangle tiled with pixels. Pixels have discrete positions. The positions of their centers are referred to as their positions, which are usually denoted by order pairs of numbers (y, x).
In most cases, the dimensions of an image will change after rotation. As shown in Figure 3, rotating the original image (the blue rectangle) around its center will produce a new image (the red rectangle) with different height and width.

Positions of pixels in the original image after rotation generally don't coincide with those of pixels in the new image. Rounding them to the nearest pixels might incur loss of image quality. An inverse transform method is used to tackle the difficulty. For each pixel in the new image, its position in the original image is computed using an inverse transform corresponding to the rotation to determine its color information.
The task is, for an image of h × w pixels and an angle α of counterclockwise rotation, to determine the dimensions in pixels of the rotated image, and for each pixel in the new image described in the coordinate system shown in Figure 2, to find its relative position in the original image described in the coordinate system shown in Figure 1.

Input

The input consists of multiple test cases.

Each test case consists of one line containing two positive integers h (1 ≤ h ≤ 128) and w (1 ≤ w ≤ 128) and a real number α (0 ≤ α ≤ 360) where h denotes the height of the image in pixels, w denotes the width of the image in pixels, α denotes the angle in degrees by which the image is rotated in counterclockwise direction.

Process to the end of input.

Output

For each test case, first output one line containing two integer H and W separated by one space meaning the new image has H × W pixels. Then output H lines each containing W coordinates representing the relative positions of pixels of the new image in the original image. If a position falls on the original image, output it in the format (y, x) with two decimal digits beyond the decimal point, otherwise output (−1.00, −1.00) instead. The coordinates are in the order in which pixels are aligned in the coordinate system shown in Figure 2. Output a blank line after each test case.

Sample Input

3 3 90
3 4 60
Sample Output

3 3
(2.00,2.00) (1.00,2.00) (0.00,2.00)
(2.00,1.00) (1.00,1.00) (0.00,1.00)
(2.00,0.00) (1.00,0.00) (0.00,0.00)

4 4
(-1.00,-1.00) (-1.00,-1.00) (-1.00,-1.00) (-1.00,-1.00)
(-1.00,-1.00) (1.93,1.88) (1.07,2.38) (0.20,2.88)
(-1.00,-1.00) (1.43,1.02) (0.57,1.52) (-1.00,-1.00)
(-1.00,-1.00) (0.93,0.15) (0.07,0.65) (-1.00,-1.00)

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.06 22:40
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Unity面板中的Rotation
在3D游戏世界中,任何一个游戏对象在创建的时候都会附带Transform(变换)组件,并且该组件是无法删除的,也不应该删除。在unity中,Transform面板一共有3个属性: Position  (位置) Rotation(旋转) Scale(缩放) 这三个值都是用来调整游戏对象在游戏界面中的位置,状态等相关参数。 Unity脚本中的变量 transf
Flex 旋转非常详细的讲解
转:http://blog.csdn.net/sjz168/article/details/6597623     自转与公转 为了更好地说明问题,先引入两个概念:“自转”和“公转”。想象一下,地球在绕着太阳公转的同时,它自己也在自转。Flash应用中的显示对象可以进行自身的自转,也可以绕着某个点公转,也可以两者同时进行。 实现旋转常用的方法 1)displayObject.rot
对QML的tranform进行改变
Flipable { id: container property alias image: frontImage.source property bool flipped: true property int xAxis: 0 property int yAxis: 0 property int angle: 0 wi
High quality image rotation (rotate by shear)
Unlike traditional rotation of images, where every n'th pixel is sampled and copied to the result image, this template provides much more accurate image rotation features (weighing the pixels). template is instantiated with a specific pixel format and must be inherited to support pixel access functions for a specific bitmap implementation. This provides abstaction of the rotation mechanism from the actual bitmap representation. Major features: ides professional quality image rotation. Code is optimized for image quality, not speed. Rotated image retains size and aspect ratio of source image (destination image size is usally bigger). Supports double precision rotation angles (0..360). Supports generic bitmap structures. Specific bitmap structure is defined by inheritance. Template based - no need for libraries, DLLs etc. No linkage problems.
matlab image rotation
this matlab program is for us to rotate the image and make some correction
image rotation and zoom
OpenCV: image rotate and zoom (rotation, zoom in and zoom out)找OpenCV rotation的时候发现的,很fantastic的code。#include "cv.h"#include "highgui.h"#include "math.h"int main( int argc, char** argv ){    IplImage*
实现图象旋转并shear的代码
Unlike traditional rotation of images, where every n'th pixel is sampled and copied to the result image, this template provides much more accurate image rotation features (weighing the pixels). <br><br>template is instantiated with a specific pixel format and must be inherited to support pixel access functions for a specific bitmap implementation. This provides abstaction of the rotation mechanism from the actual bitmap representation. <br>
UIImage 旋转 镜像 rotation mirror
来自: 点击打开链接  // UKImage.h -- extra UIImage methods // by allen brunson  march 29 2009 #ifndef UKIMAGE_H #define UKIMAGE_H #import @interface UIImage (UKImage) -(UIImage*)rotate:(UIImageOrientatio
LBP(三)
老外的原文:《Multiresolution gray-scale and rotation invariant texture classification with local binary patterns》 Timo Ojala, Matti PietikaÈ inen,2002   本文将对这篇文章做部分翻译,最后将分别给出下列代码实现 。灰度不变性LBP( gray scale i
Flex 图片调整(Matrix 矩阵)(放大/放小/左旋转/右旋转/上移/下移/左移/右移/还原/调整 ...
http://ns.adobe.com/mxml/2009"       xmlns:s="library://ns.adobe.com/flex/spark"       xmlns:mx="library://ns.adobe.com/flex/mx"       creat