Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7696197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:43:25+00:00 2026-05-31T21:43:25+00:00

I am having trouble implementing image rotation in CUDA. I have a very simple

  • 0

I am having trouble implementing image rotation in CUDA. I have a very simple Rotate function working as follows:

__device__ float readPixVal( float* ImgSrc,int ImgWidth,int x,int y)
{
    return (float)ImgSrc[y*ImgWidth+x];
}
__device__ void putPixVal( float* ImgSrc,int ImgWidth,int x,int y, float floatVal)
{
    ImgSrc[y*ImgWidth+x] = floatVal;
}

__global__ void Rotate(float* Source, float* Destination, int sizeX, int sizeY, float deg)
{
    int i = blockIdx.x * blockDim.x + threadIdx.x;// Kernel definition
    int j = blockIdx.y * blockDim.y + threadIdx.y;

    if(i < sizeX && j < sizeY)
    {
        putPixVal(Destination, sizeX, ((float)i)*cos(deg) - ((float)j)*sin(deg), ((float)i)*sin(deg) + ((float)j)*cos(deg)), readPixVal(Source, sizeX, i, j));
    }
}

The problem is, I do not know how to do any interpolation. With the above, many pixels are skipped due to integer roundoff. Anyone know how to fix this, or are there any free/opensource implementations of image rotate? I could not find any for CUDA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:43:26+00:00Added an answer on May 31, 2026 at 9:43 pm

    This seems to do the trick

    __global__ void Rotate(float* Source, float* Destination, int sizeX, int sizeY, float deg)
    {
        int i = blockIdx.x * blockDim.x + threadIdx.x;// Kernel definition
        int j = blockIdx.y * blockDim.y + threadIdx.y;
        int xc = sizeX - sizeX/2;
        int yc = sizeY - sizeY/2;
        int newx = ((float)i-xc)*cos(deg) - ((float)j-yc)*sin(deg) + xc;
        int newy = ((float)i-xc)*sin(deg) + ((float)j-yc)*cos(deg) + yc;
        if (newx >= 0 && newx < sizeX && newy >= 0 && newy < sizeY)
        {
            putPixVal(Destination, sizeX, i , j, readPixVal(Source, sizeX, newx, newy));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble implementing a trackball rotation on OpenGL. When I rotate my
Problem: I am having trouble implementing a recursive image lazy load in all relevant
I'm creating my own dictionary and I am having trouble implementing the TryGetValue function.
I have a C# MVC3 project and am having trouble implementing the HTML.CheckBoxFor. I
I have a small class hierarchy that I'm having trouble implementing copyWithZone: for. I've
I am having trouble implementing a sort. I have an XML document that I
I'm having trouble implementing a nested class who's constructor is initialized with some of
I'm having trouble implementing this step: Given I am logged in as a Facebook
Been having some trouble implementing a single-column index in LaTeX. I've been employing the
I'm having trouble understanding the instructions of implementing Fannkuch. Instructions: http://www.haskell.org/haskellwiki/Shootout/Fannkuch After step Count

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.