Thread View: comp.graphics.algorithms
5 messages
5 total messages
Started by Xiaoyi Wu
Mon, 15 Jan 1996 18:47
2D image rotation problem
Author: Xiaoyi Wu
Date: Mon, 15 Jan 1996 18:47
Date: Mon, 15 Jan 1996 18:47
12 lines
744 bytes
744 bytes
I did read the FAQ and digged up Graphics Gems, but no source code was given. So, here it comes: I need to rotate a 2D image by a specified angle with respect to a specified point within the image. Has anyone written a program like this before? I'd greatly appreciate any inputs. Thanks. Xiaoyi
Re: 2D image rotation problem
Author: Xiaoyi Wu
Date: Mon, 15 Jan 1996 20:04
Date: Mon, 15 Jan 1996 20:04
42 lines
1987 bytes
1987 bytes
Just thought I might make things a bit more clear here: The FAQ talked about doing a reverse rotation to avoid holes in the rotated image, which I followed. The question is: even if you do it the reverse way, you still end up with some pixels that fall out of the range of the source image. How do you deal with this - for now, I just arbitrarily assign them the same value as the boundary pixels. Is there a better way? Thanks. In article <4de7gt$j0i@charm.magnus.acs.ohio-state.edu>, xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu) writes: > Path: magnus.acs.ohio-state.edu!bmecg.bme.ohio-state.edu!xiaoyi > From: xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu) > Newsgroups: comp.graphics.algorithms,comp.lang.c > Subject: 2D image rotation problem > Date: 15 Jan 1996 18:47:57 GMT > Organization: Biomedical Engineering OSU > Lines: 12 > Distribution: world > Message-ID: <4de7gt$j0i@charm.magnus.acs.ohio-state.edu> > Reply-To: xiaoyi@mozart.bme.ohio-state.edu (Xiaoyi Wu) > NNTP-Posting-Host: bmecg.bme.ohio-state.edu > Xref: magnus.acs.ohio-state.edu comp.graphics.algorithms:26053 comp.lang.c:153880 > > I did read the FAQ and digged up Graphics Gems, but > no source code was given. So, here it comes: > > I need to rotate a 2D image by a specified angle with > respect to a specified point within the image. > > Has anyone written a program like this before? I'd > greatly appreciate any inputs. > > Thanks. > > Xiaoyi
Re: 2D image rotation problem
Author: Martin Leese - OMG
Date: Tue, 16 Jan 1996 15:02
Date: Tue, 16 Jan 1996 15:02
29 lines
1816 bytes
1816 bytes
On 15 Jan 1996 20:04:49 GMT Xiaoyi Wu (xiaoyi@bmecg.bme.ohio-state.edu) wrote: >> Just thought I might make things a bit more clear >> here: >> The FAQ talked about doing a reverse rotation to >> avoid holes in the rotated image, which I followed. >> The question is: even if you do it the reverse way, >> you still end up with some pixels that fall out >> of the range of the source image. How do you deal >> with this - for now, I just arbitrarily assign them >> the same value as the boundary pixels. Is there a >> better way? It really depends on your application. Typically, you would specify a background colour and assign this to the "outside" pixels. Alternatively, you could crop the output image so there aren't any "outside" pixels. The key, here, is to think about your application. It really depends on your application. Regards, Martin E-mail: mleese@omg.unb.ca WWW: http://www.omg.unb.ca/~mleese/ ________________________________________________________________________ Want to know how Ambisonics can improve the sound of your LPs and CDs? See the Ambisonic Surround Sound FAQ. Details on my WWW Home page.
Re: 2D image rotation problem
Author: Kap Shiwram
Date: Tue, 16 Jan 1996 21:31
Date: Tue, 16 Jan 1996 21:31
34 lines
2284 bytes
2284 bytes
xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu) wrote: >Just thought I might make things a bit more clear >here: > >The FAQ talked about doing a reverse rotation to >avoid holes in the rotated image, which I followed. >The question is: even if you do it the reverse way, >you still end up with some pixels that fall out >of the range of the source image. How do you deal >with this - for now, I just arbitrarily assign them >the same value as the boundary pixels. Is there a >better way? Hmm, to keep it in the range of the source image, couldn't you use AND with your index? Um, this is how I use to do it - the rotation failed but it was never out of the range of the source file. :) Um, this is assuming you're using powers of 2 for the dimensions of your image of course; if you're not then you might have to suffer a divide (eeek) i.e. use the MOD of your index into the image and the dimensions multiplied. Um, assuming your image dimensions are 32x32, ; calculate the index [si] first and si, (32*32)-1 lea si, [image+si] movsb I'm curious though.. could you explain how you did the reverse rotation? I was thinking about this and doing landscapes or flags. It always had holes in it since I was calculating the X and Y values to plot on screen but if I had just done a loop over the X and Y values then this would not have happened - instead, I would have just calculated the index into the image array and covered the entire area. The problem is, I don't know how to get the reverse function. Is it just the inverse?
Re: 2D image rotation problem
Author: Xiaoyi Wu
Date: Fri, 19 Jan 1996 14:38
Date: Fri, 19 Jan 1996 14:38
55 lines
2974 bytes
2974 bytes
Hi Kap, actually after a night's thought about it i figured it is impossible to do a rotation without creating holes unless the image is infintely large - of course you can kinda fix them by duplicating the closest pixels to the pixels that fall out of the source image. another option which seems to be the way you did it (at least the way i interprete your response) is to ignore the pixels that need to be reconstructed using non-existent pixels, and end up with a "rotated" image that has blank strips in it. for me, both would work 'cuz the object in my images are in the center so i can afford to ignore the edges. but for other applications i guess i still need to be educated. the reverse rotation is just replacing your theta with -theta :) then when you do the interpolation you will be working with pixel values you know. thanks. Xiaoyi On Tue, 16 Jan 1996, Kap Shiwram wrote: > > Hmm, to keep it in the range of the source image, couldn't you use AND > with your index? Um, this is how I use to do it - the rotation failed > but it was never out of the range of the source file. :) Um, this is > assuming you're using powers of 2 for the dimensions of your image of > course; if you're not then you might have to suffer a divide (eeek) i.e. > use the MOD of your index into the image and the dimensions multiplied. > > Um, assuming your image dimensions are 32x32, > > ; calculate the index [si] first > and si, (32*32)-1 > lea si, [image+si] > movsb > > I'm curious though.. could you explain how you did the reverse rotation? > I was thinking about this and doing landscapes or flags. It always had > holes in it since I was calculating the X and Y values to plot on screen > but if I had just done a loop over the X and Y values then this would not > have happened - instead, I would have just calculated the index into the > image array and covered the entire area. The problem is, I don't know > how to get the reverse function. Is it just the inverse? > > > Xiaoyi /=======================================================================\ | Xiaoyi Wu || If you can't convince them, confuse them. | | 614-421-0934 (h) || xiaoyi@mozart.bme.ohio-state.edu | | 614-292-1555 (o) || http://chopin.bme.ohio-state.edu/~xiaoyi/hi.html | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads