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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:15:38+00:00 2026-06-11T10:15:38+00:00

I have implemented a recursive function on image which call its neighbor pixels until

  • 0

I have implemented a recursive function on image which call its neighbor pixels until conditions get finalized, I have been able to run this code successfully upto 200×200 image resolution but when image size increases then it will get crashed with EXC_BAD_ACCESS error at the following stack line ___lldb_unnamed_function782$$libicucore.A.dylib. I have checked mine code and not able to detect any error, might be it is due to too many recursive call back functions. If anyone has any idea then please let me know.

This is mine recursive code :

 -(void)magicImageContext:(unsigned char*)data point:(CGPoint)point red:(unsigned char)red green:(unsigned char)green blue:(unsigned char)blue bytesPerPixel:(NSInteger)bytesPerPixel bytesPerRow:(NSInteger)bytesPerRow size:(long long int)size width:(NSInteger)width height:(NSInteger)height maskedData:(unsigned char*)masked_data{
for(int x = point.x-1; x<=point.x+1; x++){
    for(int y = point.y-1; y<=point.y+1; y++){
        if((x == point.x) && (y == point.y)) {
        }
        else if((x<0) || (y<0) || (x>=width) || (y>=height)){
        }
        else if([self checkPixelMarkedAtPoint:CGPointMake(x, y) data:masked_data]){
            int byteIndex = (bytesPerRow * y) + x* bytesPerPixel;
            CGFloat red2   = (data[byteIndex] );
            CGFloat green2 = (data[byteIndex + 1]);
            CGFloat blue2  = (data[byteIndex + 2]);
            if([self checkColorThresholdWithRed1:red green1:green blue1:blue red2:red2 green2:green2 blue2:blue2]){
                NSLog(@"x= %d, y= %d %d",x,y,byteIndex);
                //mark pixels on masked image
                [self changemaskedData:CGPointMake(x,y) data:masked_data];
                [self magicImageContext:data point:CGPointMake(x, y) red:red green:green blue:blue bytesPerPixel:bytesPerPixel bytesPerRow:bytesPerRow size:size width:width height:height maskedData:masked_data];                }
        }
    }
}
}
  • 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-06-11T10:15:39+00:00Added an answer on June 11, 2026 at 10:15 am

    If you’re using recursion across all the pixels of an image, then inputting a large image will certainly result in a stack overflow.

    Consider rewriting your function to use an explicit stack and a loop to avoid recursion. This also may improve the performance of your app as it avoids relatively-expensive function calls.

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

Sidebar

Related Questions

I have a recursive function (in C#) that I need to call about 800
I have a function which aims to perform a recursive calculation. If my function
If you have a recursive function that relies on some other function what is
I have a recursive function for moving some circles on a canvas. Overed circle
I have been trying to figure out how to create a treeview which is
I have implemented a recursive algorithm, to improve the performance I want to add
sorry to overflow with so many questions. I have the following: (defun recursive-function (string)
As topic said, I need a recursive function that split a string if its
I have the following recursive function: typedef unsigned long long ull; ull calc(ull b,
I have implemented correctly bump's api, and added this code: - (void) configureBump {

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.