iPad 中的洪水填充太慢了

     2023-03-12     152

关键词:

【中文标题】iPad 中的洪水填充太慢了【英文标题】:Flood filling in iPad too slow 【发布时间】:2011-05-09 01:19:28 【问题描述】:

我在 iPad 上为我的一个着色应用程序使用洪水填充。

该应用程序基本上在图像的黑线内填充颜色,我可以毫无问题地做到这一点,但它太慢了。

我首先使用递归洪水填充,它的性能是最差的(由于堆栈溢出),然后我能够使用堆栈将其转换为迭代,使用以下代码,但这太慢了

-(void)floodFillAtPoint:(CGPoint)atPoint
 
Stack *stack = [[Stack alloc] init];

[stack push:[StackPoint pointWithPoint:atPoint]];
StackPoint *currentPoint = nil;
int counter = 0;
while ((currentPoint = [stack pop])) 

    CGPoint aPoint = currentPoint.point;//CGPointMake(pointPixel.x, pointPixel.y);
    [self setColorAtPoint:aPoint];
    CGPoint bPoint = aPoint;
    bPoint.x+=1;
    if([self checkForValidRegionAtPoint:bPoint])
        [stack push:[StackPoint pointWithPoint:bPoint]];
    bPoint = aPoint;
    bPoint.x-=1;
    if([self checkForValidRegionAtPoint:bPoint])
        [stack push:[StackPoint pointWithPoint:bPoint]];
    bPoint = aPoint;
    bPoint.y+=1;
    if([self checkForValidRegionAtPoint:bPoint])
        [stack push:[StackPoint pointWithPoint:bPoint]];
    bPoint = aPoint;
    bPoint.y-=1;
    if([self checkForValidRegionAtPoint:bPoint])
        [stack push:[StackPoint pointWithPoint:bPoint]];        
    counter++;

[stack release];


有人能推荐一种最适合 iPad 设备的替代方法吗?

【问题讨论】:

Floodfill in objective c 的可能重复项 @quixoto 的答案是“使用洪水填充”。我认为不是很相关,而且绝对不是重复的。 @RVN,你能在这里分享代码吗? @EmptyStack :我已经用代码 sn-p 更新了我的问题 @florjan ,我添加了 StackPoint 类 【参考方案1】:

使用 Objective-C 对象来表示每个像素将非常缓慢并且几乎没有什么好处。

使用不同的数据结构来表示您的位图,例如各种 CG* 位图封装机制之一。然后直接旋转位图中的位。它会越来越快。

【讨论】:

嗨@bbum:我能理解你想说的话,但任何领先的开始都会有所帮助,链接或开发者指南中的主题 填充位图图像的洪水是计算机图形学 101 材料。谷歌搜索将显示数以万计的文件,这些文件正是在讨论这个问题。还有大量的 CoreGraphics 教程和示例可用。从 Apple 提供的 CoreGraphics 文档开始。 同意@bbum。如果你用 CG 位图像素的 C 数组直接用 ANSI C 重写你的 Objective C 东西,它可能会快很多。如果你不懂 C,你就不会懂 Objective C。 我使用了链表(队列)和一些结构体,速度大大提高,主要是使用的内存很低。感谢您的帮助,将尽快发布结果代码。 大家好,我已经尝试了上面的代码。它工作正常,但是我发现大图像很难。有人可以帮忙吗?【参考方案2】:

(代表问题作者发布解决方案)_。

我终于设法通过以下课程为 iPhone/iPad 制作了一个可接受的填充。如果有任何僵尸代码,请原谅:)。欢迎提出改进建议。

如何使用

创建 CanvasView 对象并设置 originalImage(这应该是带有黑线的未着色/彩色图像,黑线以外的区域必须是清晰的颜色),您可以在绘制后访问图像的 colouredImage。

.h 文件

#import <UIKit/UIKit.h>
#import "SoundEngine.h"

struct  COLOR 
    unsigned char red;
    unsigned char green;
    unsigned char blue;
    unsigned char alpha;
;

typedef struct COLOR COLOR;

@interface CanvasView : UIView 
    UIImage *originalImage;
    UIImage *coloredImage;
    int selectedColor;
    BOOL shouldShowOriginalImage;

    UIImageView *imageView;
    BOOL isImageDataFreed;

    unsigned char red;
    unsigned char green;
    unsigned char blue;
    unsigned char alpha1;
    int loopCounter;
    NSMutableArray *pixelDataArray;
    BOOL isFilling;
    BOOL hasColored;
    id delegate;
    CGPoint restartPoint;

    BOOL fillAtPoint;
    CGPoint currentTouchPoint;
    int regionCount;
    NSTimer *floadFillTimer;


@property (nonatomic, retain) UIImage *coloredImage;
@property (nonatomic, retain) UIImage *originalImage;
@property (nonatomic, retain) NSMutableArray *pixelDataArray;
@property (nonatomic, assign) id delegate;
@property (nonatomic, assign) BOOL shouldShowOriginalImage;
@property (nonatomic, assign) BOOL hasColored;
@property (assign) int regionCount;

-(void)toggleImage;
-(void)setColor:(int)colorIndex;
-(void)freeImageData;
-(CGColorRef)getColorForIndex:(int)index;
-(void)initializeCanvas;
-(void)prepareImageData;
-(void)setColorForColoring;
@end

还有.m文件

#import "CanvasView.h"
#import "PaintGame.h"
#import "Color.h"
#import "FarvespilletAppDelegate.h"
#import "Stack.h"
#import "Point.h"


@implementation CanvasView
@synthesize coloredImage,originalImage,pixelDataArray,delegate,shouldShowOriginalImage,hasColored;
@synthesize regionCount;

unsigned char *imageRawData;

-(COLOR)getPixelColorAtIndex:(CGPoint)atPoint

    COLOR aColor;

    aColor.red = 0;
    aColor.green = 0;
    aColor.blue = 0;
    aColor.alpha = 0;
    NSUInteger width = self.frame.size.width;
    NSUInteger height = self.frame.size.height;
    NSUInteger bytesPerRow = 4 * width;
    long int byteIndex = (bytesPerRow * ((NSUInteger)atPoint.y-1)) + (NSUInteger)atPoint.x*4;
    if((height * width * 4)<=byteIndex)
        return aColor;
    @try 
        aColor.red = imageRawData[byteIndex];
        aColor.green = imageRawData[byteIndex+1];
        aColor.blue = imageRawData[byteIndex+2];
        aColor.alpha = imageRawData[byteIndex+3];
    
    @catch (NSException * e) 
        NSLog(@"%@",e);
    
    @finally 

    


    return aColor;


-(void)setPixelColorAtPoint:(CGPoint)atPoint color:(COLOR)acolor

    NSUInteger width = self.frame.size.width;
    NSUInteger height = self.frame.size.height;
    NSUInteger bytesPerRow = 4 * width;
    long int byteIndex = (bytesPerRow * ((NSUInteger)atPoint.y-1)) + (NSUInteger)atPoint.x*4;
    if((height * width * 4)<=byteIndex)
        return;
    @try 
        imageRawData[byteIndex] = acolor.red;
        imageRawData[byteIndex+1] = acolor.green;
        imageRawData[byteIndex+2] = acolor.blue;
        imageRawData[byteIndex+3] = acolor.alpha;
    
    @catch (NSException * e) 
        NSLog(@"%@",e);
    
    @finally 

    



-(void)initializeCanvas

    imageView = [[UIImageView alloc] initWithFrame:self.bounds];
    [self addSubview:imageView];
    self.backgroundColor = [UIColor clearColor];
    [imageView release];
    isImageDataFreed = YES; 
    isFilling = NO;


- (id)initWithFrame:(CGRect)frame 

    self = [super initWithFrame:frame];
    if (self) 
        // Initialization code.
        [self initializeCanvas];
    
    return self;



// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect 
    // Drawing code.
    if(!imageRawData)
        [self prepareImageData];
    if(shouldShowOriginalImage)
        imageView.image = originalImage;
    else
        imageView.image = coloredImage;



- (void)dealloc 
    [super dealloc];
    [originalImage release];
    [coloredImage release];
    [pixelDataArray release];



-(BOOL)isColorStandardForRed:(unsigned char)__red green:(unsigned char)__green blue:(unsigned char)__blue

    if(0 == __red && 0 == __green && 0 == __blue)
        return NO;
    else
        return YES;


-(BOOL)checkForValidRegionAtPoint:(CGPoint)touchPoint

    COLOR colorAtPoint = [self getPixelColorAtIndex:touchPoint];
    loopCounter++;
    unsigned char _red   = colorAtPoint.red;
    unsigned char _green = colorAtPoint.green;
    unsigned char _blue  = colorAtPoint.blue;
    unsigned char _alpha1 = colorAtPoint.alpha;

    if(touchPoint.x <= 0 || touchPoint.y <= 0 || touchPoint.x >= self.frame.size.width ||touchPoint.y >= self.frame.size.height)
        return NO;
    if(red == _red && green == _green && blue == _blue && alpha1 == _alpha1)
        return NO;
    if(_alpha1 <= 225)
        return NO;
    if(_red <= 50 && _green <= 50 && _blue <= 50 && _alpha1 == 255)
        return NO;
    if(!([self isColorStandardForRed:_red green:_green blue:_blue]))
        return NO;
    return YES;


-(void)setColorAtPoint:(CGPoint)atPoint

    //loopCounter++;
    COLOR aColor;
    aColor.red = red;
    aColor.green = green;
    aColor.blue = blue;
    aColor.alpha = alpha1;

    [self setPixelColorAtPoint:atPoint color:aColor];


-(void)prepareImageData

    if(!imageRawData)
    
        CGImageRef imageRef = [coloredImage CGImage];
        NSUInteger bytesPerPixel = 4;
        NSUInteger width = self.frame.size.width;
        NSUInteger height = self.frame.size.height;//CGImageGetHeight(imageRef);
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

        NSUInteger bytesPerRow = bytesPerPixel * width;
        NSUInteger bitsPerComponent = 8;
        imageRawData = malloc(height * width * 4);
        CGContextRef context = CGBitmapContextCreate(imageRawData, width, height,
                                                     bitsPerComponent, bytesPerRow, colorSpace,
                                                     kCGImageAlphaPremultipliedLast);
        CGColorSpaceRelease(colorSpace);
        CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
        CGContextRelease(context);
    


-(void)cleanUpImageData

    NSUInteger bytesPerPixel = 4;
    NSUInteger width = self.frame.size.width;
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    NSUInteger bytesPerRow = bytesPerPixel * width;
    CGContextRef ctx = CGBitmapContextCreate(imageRawData,  
                                             self.frame.size.width,  
                                             self.frame.size.height,  
                                             8,  
                                             bytesPerRow,  
                                             colorSpace,  
                                             kCGImageAlphaPremultipliedLast);  
    CGImageRef newImageRef = CGBitmapContextCreateImage(ctx);  
    CGContextRelease(ctx);
    self.coloredImage = [UIImage imageWithCGImage:newImageRef];  
    CGImageRelease(newImageRef);


-(void)refreshImage

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [self cleanUpImageData];
    imageView.image = coloredImage;
    [pool release];



typedef struct queue_  struct queue_ *next;  queue_t;
typedef struct ffnode_  queue_t node; int x, y;  ffnode_t;

/* returns the new head of the queue after adding node to the queue */
queue_t* enqueue(queue_t *queue, queue_t *node) 
    if (node) 
        if(!queue)
            return node;
        queue_t *temp = queue; 
        while(temp->next)
            temp = temp->next;
        temp->next = node;

       // node->next = queue;
        return queue;
    
    return NULL;


/* returns the head of the queue and modifies queue to be the new head */
queue_t* dequeue(queue_t **queue) 
    if (queue) 
        queue_t *node = (*queue);
        if(node)
        
            (*queue) = node->next;
            node->next = NULL;
            return node;   
        
    
    return NULL;


ffnode_t* new_ffnode(int x, int y) 
    ffnode_t *node = (ffnode_t*)malloc(sizeof(ffnode_t));
    node->x = x; node->y = y;
    node->node.next = NULL;
    return node;


-(void)floodFillAtPoint:(CGPoint)atPoint shouldRefresh:(BOOL)refresh


    queue_t *head = NULL;
    ffnode_t *node = NULL;

    node = new_ffnode(atPoint.x, atPoint.y);
    head = enqueue(head, &node->node);
    long int counter = 0;
    [self setColorAtPoint:atPoint];

    while((node = (ffnode_t*)dequeue(&head))) 
    
        counter++;
        CGPoint aPoint = CGPointMake(node->x, node->y);
        free(node);
        CGPoint bPoint = aPoint;
        bPoint.x+=1;
        if([self checkForValidRegionAtPoint:bPoint])
        
            ffnode_t *node1 = new_ffnode(bPoint.x, bPoint.y); 
            head = enqueue(head, &node1->node);
            [self setColorAtPoint:bPoint];
        
        bPoint = aPoint;
        bPoint.x-=1;
        if([self checkForValidRegionAtPoint:bPoint])
        
            ffnode_t *node1 = new_ffnode(bPoint.x, bPoint.y); 
            head = enqueue(head, &node1->node);
            [self setColorAtPoint:bPoint];
               
        bPoint = aPoint;
        bPoint.y+=1;
        if([self checkForValidRegionAtPoint:bPoint])
        
            ffnode_t *node1 = new_ffnode(bPoint.x, bPoint.y); 
            head = enqueue(head, &node1->node);
            [self setColorAtPoint:bPoint];
        
        bPoint = aPoint;
        bPoint.y-=1;
        if([self checkForValidRegionAtPoint:bPoint])
        
            ffnode_t *node1 = new_ffnode(bPoint.x, bPoint.y); 
            head = enqueue(head, &node1->node);
            [self setColorAtPoint:bPoint];
        
    
    if(refresh)
        [self performSelectorOnMainThread:@selector(shouldRefresh) withObject:nil waitUntilDone:YES];    



-(void)shouldRefresh

    self.regionCount += 1;
    //To detect if all the region/thread are completed; if YES then notify the delegate
    if(regionCount==9)
    
        [floadFillTimer invalidate];
        isFilling = NO;
        [delegate fillingStateChanged:isFilling];
    
    [self cleanUpImageData];
    imageView.image = coloredImage;


-(void)floodFillInBackGroundAtPoint:(StackPoint*)point

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [self floodFillAtPoint:point.point shouldRefresh:YES];
    [pool release];


-(void)floodFillInBackGroundAtPointWithRefresh:(StackPoint*)point

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [self floodFillAtPoint:point.point shouldRefresh:YES];
    [pool release];


-(void)initiateFloodFillAtPoint:(CGPoint)touchPoint

    loopCounter = 0;
    isFilling = YES;
    [delegate fillingStateChanged:isFilling];
    hasColored = YES;
    regionCount = 0;

    floadFillTimer = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector(refreshImage) userInfo:nil repeats:YES];
    [[NSRunLoop mainRunLoop] addTimer:floadFillTimer forMode:NSDefaultRunLoopMode];
    StackPoint *stackPoint = [StackPoint pointWithPoint:touchPoint];

    CGPoint floodPoint = touchPoint;

    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.x++;
    
    floodPoint.x--;
    StackPoint *stackPoint1 = [StackPoint pointWithPoint:floodPoint];

    floodPoint = touchPoint;
    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.x--;
    
    floodPoint.x++;
    StackPoint * stackPoint2 = [StackPoint pointWithPoint:floodPoint];
    floodPoint = touchPoint;
    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.y++;
    
    floodPoint.y--;
    StackPoint *stackPoint3 = [StackPoint pointWithPoint:floodPoint];
    floodPoint = touchPoint;
    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.y++;
    
    floodPoint.y--;
    StackPoint *stackPoint4 = [StackPoint pointWithPoint:floodPoint];


    floodPoint = touchPoint;

    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.x++;
        floodPoint.y++;
    
    floodPoint.x--;
    floodPoint.y--;
    StackPoint *stackPoint5 = [StackPoint pointWithPoint:floodPoint];

    floodPoint = touchPoint;
    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.x--;
        floodPoint.y--;
    
    floodPoint.x++;
    floodPoint.y++;
    StackPoint * stackPoint6 = [StackPoint pointWithPoint:floodPoint];
    floodPoint = touchPoint;
    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.x++;
        floodPoint.y--;
    
    floodPoint.x--;
    floodPoint.y++;
    StackPoint *stackPoint7 = [StackPoint pointWithPoint:floodPoint];
    floodPoint = touchPoint;
    while ([self checkForValidRegionAtPoint:floodPoint])
    
        floodPoint.x--;
        floodPoint.y++;
    
    floodPoint.x++;
    floodPoint.y--;
    StackPoint *stackPoint8 = [StackPoint pointWithPoint:floodPoint];


    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint];    
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint1];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint2];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint3];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint4];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint5];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint6];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint7];
    [self performSelectorInBackground:@selector(floodFillInBackGroundAtPoint:) withObject:stackPoint8];


-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

    UITouch *aTouch = [touches anyObject];
    CGPoint aPoint = [aTouch locationInView:imageView];
    [self setColorForColoring];
    //This will toggle from uncolored state to colored state, also resets the colored image
    if(shouldShowOriginalImage)
    
        self.coloredImage = originalImage;
        shouldShowOriginalImage = !shouldShowOriginalImage;
        [self freeImageData];
        [self prepareImageData];
        [delegate coloringStarted];
    
    if([self checkForValidRegionAtPoint:aPoint] && !isFilling)
    
        [self setColorForColoring];
        self.userInteractionEnabled = NO;
        [self initiateFloodFillAtPoint:aPoint];
        self.userInteractionEnabled = YES;
        NSString *fileName = [NSString stringWithFormat:@"splat%d",(rand()%10)+1];
        [[SoundEngine sharedSoundEngine] playSoundWithFileName:fileName delegate:nil];
    


-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

    UITouch *aTouch = [touches anyObject];
    CGPoint aPoint = [aTouch locationInView:self];
    [self setColorForColoring];
    //This will toggle from uncolored state to colored state, also resets the colored image
    if(shouldShowOriginalImage)
    
        self.coloredImage = originalImage;
        shouldShowOriginalImage = !shouldShowOriginalImage;
        [self freeImageData];
        [self prepareImageData];
        [delegate coloringStarted];
    
    if([self checkForValidRegionAtPoint:aPoint] && !isFilling)
    
        [self setColorForColoring];
        self.userInteractionEnabled = NO;
        [self initiateFloodFillAtPoint:aPoint];
        self.userInteractionEnabled = YES;
        NSString *fileName = [NSString stringWithFormat:@"splat%d",(rand()%10)+1];
        [[SoundEngine sharedSoundEngine] playSoundWithFileName:fileName delegate:nil];
//        [self cleanUpImageData];
//        [self setNeedsDisplay];
    



-(void)toggleImage

    shouldShowOriginalImage = !shouldShowOriginalImage;
    [self setNeedsDisplay];


-(void)setColorForColoring

    const CGFloat *colorComponents = CGColorGetComponents([self getColorForIndex:selectedColor]);
    red   =  (unsigned char)(colorComponents[0]*255);
    green =  (unsigned char)(colorComponents[1]*255);
    blue  = (unsigned char)(colorComponents[2]*255);
    alpha1 = (unsigned char)(CGColorGetAlpha([self getColorForIndex:selectedColor])*255);



-(void)setColor:(int)colorIndex

    selectedColor = colorIndex;
    //const CGFloat *colorComponents = CGColorGetComponents([self getColorForIndex:selectedColor]);
//  red   =  (unsigned char)(colorComponents[0]*255);
//  green =  (unsigned char)(colorComponents[1]*255);
//  blue  = (unsigned char)(colorComponents[2]*255);
//  alpha1 = (unsigned char)(CGColorGetAlpha([self getColorForIndex:selectedColor])*255);


-(void)cleanBuffer

    if(imageRawData)
    
        int width = self.frame.size.width;
        int height = self.frame.size.height;
        int byteIndex = 0;
        for (int ii = 0 ; ii < (width*height*4) ; ++ii)
        
            imageRawData[byteIndex] = 0;
            imageRawData[byteIndex + 1] = 0;
            imageRawData[byteIndex + 2] = 0;
            imageRawData[byteIndex + 3] = 255;
                   
    


-(void)freeImageData

    self.pixelDataArray = nil;
    free(imageRawData);
    imageRawData = NULL;


-(CGColorRef)getColorForIndex:(int)index

    switch (index) 
    
        case 1:
            return [[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] CGColor];
        case 2:
            return [[UIColor colorWithRed:0.200f green:0.200f blue:0.200f alpha:1.0f] CGColor];
        case 3:
            return [[UIColor redColor] CGColor];
        case 4:
            return [[UIColor colorWithRed:0.062f green:0.658f blue:0.062f alpha:1.0f] CGColor];
        case 5:
            return [[UIColor blueColor] CGColor];
        case 6:
            return [[UIColor yellowColor] CGColor];
        case 7:
            return [[UIColor orangeColor] CGColor];
        case 8:
            return [[UIColor brownColor] CGColor];
        case 9:
            return [[UIColor colorWithRed:0.7f green:0.7f blue:0.7f alpha:1.0f] CGColor];
        case 10:
            return [[UIColor purpleColor] CGColor];
        default:
            break;
    


    return [[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] CGColor];


@end

附加信息:

StackPoint.h

    @interface StackPoint : NSObject 
        CGPoint point;
    

    @property (nonatomic , assign) CGPoint point;
    +(StackPoint*)pointWithPoint:(CGPoint)_point;
    @end

堆栈点.m

    @implementation StackPoint
    @synthesize point;

    +(StackPoint*)pointWithPoint:(CGPoint)_point
    
        StackPoint *__point = [[StackPoint alloc] init];
        __point.point = _point;
        return [__point autorelease];
    

    -(id)init
    
        self = [super init];
        if(self)
        
            point = CGPointZero;
        
        return self;
    

    @end

【讨论】:

Swift:tableView.reloadData() 太慢了

...】:2015-08-2317:06:01【问题描述】:我正在尝试在我调用以填充我的UITableView的异步请求之后执行tableView.reloadData()调用。该表会在15-20秒后显示数据,除非我手动开始滚动,在这种情况下它会立即加载。所以数据肯定在那里,只是... 查看详情

Vector 中的 1000 多个游戏对象太慢了?我的错误是啥?

】Vector中的1000多个游戏对象太慢了?我的错误是啥?【英文标题】:1000+Game-ObjectsinVectortooslow?Whatismymistake?Vector中的1000多个游戏对象太慢了?我的错误是什么?【发布时间】:2015-04-0714:51:04【问题描述】:我目前正在开发一款需... 查看详情

Rabin Karp 在 Ruby 中的实现太慢了

】RabinKarp在Ruby中的实现太慢了【英文标题】:RabinKarpImplementationtooslowinRuby【发布时间】:2011-12-3017:47:16【问题描述】:我一直在研究一个小型抄袭检测引擎,它使用来自MOSS的Idea。我需要一个RollingHash函数,我的灵感来自Rabin-Karp... 查看详情

PostgreSQL join 获取表中的所有行,太慢了

】PostgreSQLjoin获取表中的所有行,太慢了【英文标题】:PostgreSQLjoinfetchallrowsintable,tooslow【发布时间】:2014-11-1123:50:45【问题描述】:我有两个表“commissions”和“mt4_trades”。在“mt4_trades”中,“ticket”列是私钥,在“commissions... 查看详情

插入 WStandardItemModel 太慢了

...rdItemModel关联的WTableView中显示大量数据。对于要添加到表中的每个新项目:model->setData(row,column 查看详情

获取数百万条记录太慢了

...述】:我正在尝试使用带有Fetching的聚集索引复制其他表中的6000万条记录。但是在2000万张唱片之后,它变得太慢了。我不知道我该怎么做。任何人都可以帮助我吗?这是我的计时。1000000百万分钟:12000000百万分钟:03000000百万分... 查看详情

洪水填充图像的图像处理

...目中我用洪水填充了原始图像。现在我需要去除这张图片中的噪点,即手部图像周围的白线。我想通过将这些白线合并到黑色背景色中来删除它们。我需要将洪水填充区域的灰色(值为127)更改为白色。请注意,背景颜色应保持... 查看详情

如何在 Pygame 表面中实现洪水填充

...ygame表面的好方法。我想要的最好的例子是油漆桶在MSPaint中的工作方式。例如,如果在白色表面上画了一个黑色圆圈,我想在圆圈内填充白色(或任何形状)。为了让您了解我在做什么,我正在制作一个像素艺术工具,并且我正... 查看详情

sqlmap太慢了

】sqlmap太慢了【英文标题】:sqlmapistooslow【发布时间】:2012-07-0506:46:16【问题描述】:这是一个例子。只是想列出数据库:pythonsqlmap.py-u"http://somesite.com/?id=1"--dbs[15:20:32][INFO]fetchingdatabasenames[15:20:32][INFO]fetchingnumberofdatabases[... 查看详情

for循环太慢了

】for循环太慢了【英文标题】:Forloopistooslow【发布时间】:2016-01-0113:01:38【问题描述】:我有以下代码:varCombinatorics=require(\'js-combinatorics\');varfs=require(\'fs\');cp=Combinatorics.cartesianProduct(["4","@","/\\\\","/-\\\\","^","∂","λ","α","(!" 查看详情

太慢的最短路径算法[关闭]

...等于D时,这些点才能连接,我有起始索引和完成(代码中的“ciel”)索引并且必须以双格式返回最短路径。一开始我以为sqrt太慢了,但是当我改变它时,它仍然太慢了。我正在回溯 查看详情

InAppReview : SKStoreReviewController 太慢了

】InAppReview:SKStoreReviewController太慢了【英文标题】:InAppReview:SKStoreReviewControllerSoSlow【发布时间】:2017-09-2213:03:59【问题描述】:使用SKStoreReviewController进行inAppReview需要时间,直到出现提示,有什么方法可以让它显示得更快?另... 查看详情

Ucanaccess 太慢了

】Ucanaccess太慢了【英文标题】:Ucanaccessistooslow【发布时间】:2016-04-2708:03:07【问题描述】:我已正确添加了所有必要的JARS:Ucanaccess3.0.4commons-lang-2.6commons-logging-1.1.1hsqldbdjackcess-2.1.3我的数据库是100MB。仅使用Jacksess时,相同的查... 查看详情

为啥使用 information_schema 太慢了?

】为啥使用information_schema太慢了?【英文标题】:Whyisusinginformation_schematoomuchslow?为什么使用information_schema太慢了?【发布时间】:2017-02-2607:34:33【问题描述】:这是我的代码://dbssize$sql=\'SELECTtable_schemaDB_Name,Round(Sum(data_length+inde... 查看详情

导航到包含 ScrollView 的 ViewController 太慢了

】导航到包含ScrollView的ViewController太慢了【英文标题】:NavigatingtoViewControllercontainingScrollViewGoingtooSlow【发布时间】:2016-01-1807:55:50【问题描述】:这就是从ViewControllerA推送到ViewControllerB的方式UIStoryboard*mainStory=[UIStoryboardstoryboardW... 查看详情

如何最佳解决洪水填充难题?

】如何最佳解决洪水填充难题?【英文标题】:Howtooptimallysolvethefloodfillpuzzle?【发布时间】:2010-11-2816:38:34【问题描述】:我喜欢玩益智游戏Flood-It,可以在线玩:https://www.lemoda.net/javascript/flood-it/game.html它也可以作为iGoogle小工具... 查看详情

呈现视图控制器太慢了

】呈现视图控制器太慢了【英文标题】:PresentingViewControlleristooslow【发布时间】:2020-05-2000:08:29【问题描述】:我已经在我的Swift应用中实现了FirebaseGoogle登录。我想在开始时检查它是否已经是登录用户。我是这样做的:overridefun... 查看详情

MySQL查询太慢了

】MySQL查询太慢了【英文标题】:MySQLquerytoomuchslow【发布时间】:2019-05-1423:21:59【问题描述】:我正在尝试查询以获取一些趋势统计数据,但基准测试真的很慢。查询执行时间约为134秒。我有一个名为table_1的MySQL表。在create语句... 查看详情