944,070 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 28873
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 22nd, 2004
0

image rotation

Expand Post »
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 :-|
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
dalaharp is offline Offline
31 posts
since Oct 2004
Nov 22nd, 2004
0

Re: image rotation

>>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?
Reputation Points: 17
Solved Threads: 9
Posting Whiz in Training
frrossk is offline Offline
220 posts
since Sep 2004
Nov 24th, 2004
0

Re: image rotation

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];
}
}
---------------------------------------
:-?
Reputation Points: 10
Solved Threads: 0
Light Poster
dalaharp is offline Offline
31 posts
since Oct 2004
Nov 24th, 2004
0

Re: image rotation

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.
Reputation Points: 17
Solved Threads: 9
Posting Whiz in Training
frrossk is offline Offline
220 posts
since Sep 2004
Nov 29th, 2004
0

Re: image rotation

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.
Reputation Points: 13
Solved Threads: 2
Newbie Poster
glSuccinct is offline Offline
13 posts
since Aug 2004
Feb 5th, 2008
-1

Re: image rotation

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
Reputation Points: 4
Solved Threads: 0
Newbie Poster
sarinsukumar is offline Offline
3 posts
since Feb 2008
Feb 24th, 2009
-1

Re: image rotation

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???
Reputation Points: 4
Solved Threads: 0
Newbie Poster
mj_crookshanks is offline Offline
1 posts
since Feb 2009
Feb 24th, 2009
0

Re: image rotation

If its' on Windows, just use win32 api
(1 line of code..)
Reputation Points: -76
Solved Threads: 14
Junior Poster
marco93 is offline Offline
132 posts
since Apr 2008
Feb 24th, 2009
1

Re: image rotation

Click to Expand / Collapse  Quote originally posted by marco93 ...
If its' on Windows, just use win32 api
(1 line of code..)
Go ahead then, tell us how to do it in one line.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Aug 13th, 2010
0
Re: image rotation
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 ..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Karan_111 is offline Offline
1 posts
since Aug 2010

This thread is more than three months old

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.
Message:
Previous Thread in C Forum Timeline: Average of an Array
Next Thread in C Forum Timeline: shared array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC