J'ai implémenté une fonction récursive sur l'image qui appelle ses pixels voisins jusqu'à ce que les conditions soient finalisées, j'ai réussi à exécuter ce code jusqu'à 200x200 résolution d'image mais quand la taille de l'image augmente va se briser avec EXC_BAD_ACCESS
erreur à la ligne de pile suivante ___ lldb_unnamed_function782 $$ libicucore.A.dylib. J'ai vérifié le code de ma mine et je n'ai pas pu détecter d'erreur, peut-être parce que trop de fonctions de rappel sont récursives. Si quelqu'un a une idée alors s'il vous plaît faites le moi savoir.erreur EXC_BAD_ACCESS lors d'une résolution d'image importante
Ceci est du code récursif mien:
-(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]; }
}
}
}
}
Si vous avez résolu le problème, pourriez-vous coller le code qui a fait le tour? – Levi