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 6873765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:06:38+00:00 2026-05-27T04:06:38+00:00

I am working on an application, which has to use pixel manipulation in the

  • 0

I am working on an application, which has to use pixel manipulation in the following way: around a point(x,y) I have to condense or expand the pixels in a circle of radius R, but I want to keep the rectangular frame of the UIImage. I get the raw data n the following way (I found this on the web):

CGImageRef imageRef = image.CGImage;

NSUInteger width = CGImageGetWidth(imageRef);
NSUInteger height = CGImageGetHeight(imageRef);
CFDataRef dataref = CopyImagePixels(imageRef);

unsigned char *rawData = CFDataGetBytePtr(dataref);

So, I have in rawData the pixel data.

int byteIndex = 0;
for (int ii = 0 ; ii < width * height ; ++ii)
{
    //now rawData[baseIndex] stands for red
    //rawData[baseIndex + 1] stands for green
    //rawData[baseIndex + 2] stands for blue

    byteIndex += 4;
}

Now, how do I know if the current pixel is within the circle of origin(x,y) and of radius R?
And how do I condense/expand these pixels?

Thanks

  • 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-27T04:06:38+00:00Added an answer on May 27, 2026 at 4:06 am

    Use pythagorus’ theorem – a2 + b2 = c2

    c2 is easy:

    CGFloat maxDistance = R*R;
    

    For each pixel, given its position (xp, yp) – which you can maintain in your loop – get the square of the distance from the origin and compare to maxDistance:

    int byteIndex = 0;
    CGFloat xp = 0;
    CGFloat yp = 0;
    
    for (int ii = 0 ; ii < width * height ; ++ii)
    {
        CGFloat xDist = xp - x;
        CGFloat yDist = yp - y;
    
        CGFloat dist = sqrt((xDist * xDist + yDist * yDist)) // Squares will be positive for comparison below...
    
        if (dist <= maxDistance) {
            ...
        }
    
        byteIndex += 4;
        if (++xp > width) {
            xp = 0;
            yp++;
        }
    }
    

    I don’t know what you mean be condensing the pixels, but I’m sure that you can work out what you need to do now…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a java application which has a lot of use cases.
I have a working web application which already has a login and registration system.
I am trying to use JNotify for my application , which has the following
I am working on an application which has a registration form and I have
I'm working on an application which has data imported from a foreign (and wholly
I’m working on an application which has been designed using n-tire application architecture .The
I am working on an application which has got some sensitive information. I am
I am working on a WPF application which has a treeview that represents an
We are working with a PHP application which has no concept of switch-able themes;
Well, simple question. I'm working with VS2008 on an ASP.NET web application which has

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.