gpt4 book ai didi

ios - 如何将图像分成多个部分进行图像处理,然后重新组合?

转载 作者:行者123 更新时间:2023-12-01 22:48:22 25 4
gpt4 key购买 nike

我正在使用Core Image和GPUImage在iPhone应用程序中进行一些过滤。我似乎内存不足,并且崩溃了大图。我认为如果我可以将输入图像分成多个部分,就可以解决。

如何有效地将图像分成多个部分进行图像处理,然后重新组合以在iOS中整体输出结果图像?

最佳答案

-(void)getMultipleImages:(UIImage*)image AndNumberOfPart:(NSInteger)matrixSize{



CGSize size = image.size;

//for storing rect values of puzzle boxess
NSMutableArray *puzzleRectArr = [[NSMutableArray alloc]init];
NSMutableArray *puzzleCroppedObj = [[NSMutableArray alloc]init];

int widthD = size.width;
int heightD = size.height;

float boxWidth = widthD/matrixSize;
float boxHeight = heightD/matrixSize;


for (int i = 0; i < matrixSize*matrixSize; i++) {

int x = (widthD/matrixSize)/2 + (widthD/matrixSize) *(i%matrixSize)-boxWidth/2;
int y = (heightD/matrixSize)/2 + (heightD/matrixSize)* (i/matrixSize)-boxHeight/2;


CGRect rect = CGRectMake(x, y, boxWidth, boxHeight);
[puzzleRectArr addObject:[NSValue valueWithCGRect:rect]];

CGImageRef imageRef = CGImageCreateWithImageInRect([self.imgActual CGImage], rect);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
//----------------------------------------------------------------------
//here You can find the part image
[puzzleCroppedObj addObject:croppedImage];

//----------------------------------------------------------------------


CGImageRelease(imageRef);
}
}

关于ios - 如何将图像分成多个部分进行图像处理,然后重新组合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13193748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com