image rotation

Reply

Join Date: Oct 2004
Posts: 31
Reputation: dalaharp is an unknown quantity at this point 
Solved Threads: 0
dalaharp dalaharp is offline Offline
Light Poster

image rotation

 
0
  #1
Nov 22nd, 2004
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 :-|
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: image rotation

 
0
  #2
Nov 22nd, 2004
>>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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 31
Reputation: dalaharp is an unknown quantity at this point 
Solved Threads: 0
dalaharp dalaharp is offline Offline
Light Poster

Re: image rotation

 
0
  #3
Nov 24th, 2004
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];
}
}
---------------------------------------
:-?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: image rotation

 
0
  #4
Nov 24th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 13
Reputation: glSuccinct is an unknown quantity at this point 
Solved Threads: 1
glSuccinct's Avatar
glSuccinct glSuccinct is offline Offline
Newbie Poster

Re: image rotation

 
0
  #5
Nov 29th, 2004
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.
-don't listen to me-
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1
Reputation: sarinsukumar has a little shameless behaviour in the past 
Solved Threads: 0
sarinsukumar sarinsukumar is offline Offline
Newbie Poster

Re: image rotation

 
-1
  #6
Feb 5th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1
Reputation: mj_crookshanks has a little shameless behaviour in the past 
Solved Threads: 0
mj_crookshanks mj_crookshanks is offline Offline
Newbie Poster

Re: image rotation

 
-1
  #7
Feb 24th, 2009
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???
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 118
Reputation: marco93 is infamous around these parts marco93 is infamous around these parts marco93 is infamous around these parts 
Solved Threads: 12
marco93 marco93 is offline Offline
Junior Poster

Re: image rotation

 
0
  #8
Feb 24th, 2009
If its' on Windows, just use win32 api
(1 line of code..)
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,405
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 114
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: image rotation

 
1
  #9
Feb 24th, 2009
Originally Posted by marco93 View Post
If its' on Windows, just use win32 api
(1 line of code..)
Go ahead then, tell us how to do it in one line.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC