hi,
i have to rotate an image. the image is stored in an image[rows][cols] array..
i am trying to rotate it using trignometric functions.
i am not sure what happens when i rotate the image,
does the address of the pixel vary or the value of the pixel vary.
and when i rotate an image by say 45 degrees, then wont it fall out of the gird?
please clear my doubts :-|
>>does the address of the pixel vary or the value of the pixel vary.
Depends how you see this matter: let's assume the rotation center is the center of the image. So, rotating the image means the pixel p[x][y] will have the value that was allocated to the pixel p[x1][y1] - the value of the pixel vary. Or, the value GREEN that was on the pixel p[x][y] will be, after rotation, in the pixel p[x1][y1] - the address of the pixel vary () (I assumed "the address of the pixel" is the position of a pixel with a certain value)
>>when i rotate an image by say 45 degrees, then wont it fall out of the gird
If your image is rectangular, imagine that rotating it will change it's position on the screen like you will rotate a sheet of paper on the table. How will differ these two positions?
i tried this code for rotating,
but for r1 and c1, i am getting negative values..
and the rotation is also not proper..
------------------------------------
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
r1=(i*cos(angle))-(j*sin(angle));
c1=(i*sin(angle))+(j*cos(angle));
rot_image[r1][c1]=image[i][j];
}
}
---------------------------------------
:-?
I think the correct relations are more like
r1 = iorig + (i - iorig)sin(angle)
c1 = jorig + (j - jorig)cos(angle)
where iorig, jorig are th ecoordinates of the rotation center.
(but I'm not too sure - it's a long time since I did some trigonometry()
And, also, there is possible to obtain negative values for the new coordinates, since they are reported to the coordinates of the rotation origin.
If you rotate a square image about it's center, clipping will occur on all sides. The most clipping will occur when the image is rotated by a multiple of 45 degress. At a multiple of 45 degrees, any part of the image extending past the original boundries will clip, which is anything about ImageWidth*cos(PI/4) (or ImageWidth*sqrt(2)/2) along the line from the center to a corner's worth of pixels. The only way to do it and keep all of the data is to make the boundries of the image larger. The easiest way is to have a source and dest images, where dest is approximately sqrt(2) larger in each dimension for all rotations, or variations of 1.0f/cos(Angle) or 1.0f/sin(Angle) depending on the range of angles to avoid asymptotes.
hey u can rotate an image by using c,,,just use geometric equations and u must have a good knowkedge about cordinate systems , and frame of referances ..i achived it .but the problem is that it losses quality..
there is a problem when rounding the digit .. if u have any doubt u pls mail me...
<email snipped>
....here im doing a project on that.............
Last edited by WolfPack; Feb 5th, 2008 at 5:04 am. Reason: Removed email as per forum rule : Keep it within the site
hi i am also doing a project on image rotation and need to know how it is done. could you please tell me how to go about it.your email address was not posted though. would be obliged if u could inform me as soon as possible.am also trying image translation and warping.any ideas???
I have a problem i wanted to rotate a picture and calculate the time taken using "C" programming language ..Its really very urgent .. Please help me out ..
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.