//灰度图像膨胀 void Dilate_Gray(double *src,double *dst,int width,int height,double *se,int sewidth,int seheight,Position *center){ int SEissmooth=isSmooth(se,sewidth,seheight); double *temp=(double*)(malloc(sizeof(double)*width*height)); double *temp_last=(double*)(malloc(sizeof(double)*width*height)); Position centerde; centerde.x=sewidth/2; centerde.y=seheight/2; if(center==NULL){ center=¢erde; } matrixCopy(src,temp_last,width,height); for(int j=0;j<seheight;j++) for(int i=0;i<sewidth;i++){ matrixCopy(src,temp,width,height); double value=se[j*width+i]; if(value!=0.0){ Position d; d.x=center->x-i; d.y=center->y-j; if(SEissmooth) G_Translation(temp, temp,width,height, 0.0, &d,TOFINDMAX); else G_Translation(temp, temp,width,height, value, &d,TOFINDMAX); MaxPix(temp, temp_last, temp_last,width,height); } } matrixCopy(temp_last, dst,width,height); free(temp); free(temp_last); }
bool BigTexture::loadFromImage(const sf::Image& source) { // Rollback semantics: In case of failure, *this remains unchanged BigTexture tmp; const unsigned int maxSize = sf::Texture::getMaximumSize(); tmp.mPixelSize = source.getSize(); // Number of textures needed, in X and Y direction tmp.mTableSize.x = (tmp.mPixelSize.x - 1u) / maxSize + 1u; tmp.mTableSize.y = (tmp.mPixelSize.y - 1u) / maxSize + 1u; tmp.mTextures.clear(); tmp.mTextures.reserve(tmp.mTableSize.x * tmp.mTableSize.y); // Create sf::Textures that form together the big texture for (unsigned int y = 0u; y < tmp.mPixelSize.y; y += maxSize) { for (unsigned int x = 0u; x < tmp.mPixelSize.x; x += maxSize) { // Note: sf::Texture::loadFromImage() reduces the rectangle size if necessary tmp.mTextures.push_back(sf::Texture()); if (!tmp.mTextures.back().loadFromImage(source, sf::IntRect(x, y, maxSize, maxSize))) return false; } } // Apply smooth filter tmp.setSmooth(isSmooth()); // Success: Commit modifications swap(tmp); return true; }
//测地腐蚀 void Erode_Gray_g(double *src,double *ground,double *dst,int width,int height,double *se,int sewidth,int seheight,Position *center){ int SEissmooth=isSmooth(se,sewidth,seheight); double *temp=(double*)malloc(sizeof(double)*width*height); double *temp_last=(double*)malloc(sizeof(double)*width*height); Position centerde; centerde.x=sewidth/2; centerde.y=seheight/2; if(center==NULL){ center=¢erde; } matrixCopy(src,temp_last,width,height); for(int j=0;j<seheight;j++) for(int i=0;i<sewidth;i++){ matrixCopy(src,temp,width,height); double value=se[j*sewidth+i]; if(value!=0.0){ Position d; d.x=i-center->x; d.y=j-center->y; if(SEissmooth) G_Translation(temp, temp,width,height, 0.0, &d,TOFINDMIN); else G_Translation(temp, temp,width,height, -1.0*value, &d,TOFINDMIN); MinPix(temp, temp_last, temp_last,width,height); } } MaxPix(temp_last,ground,temp_last,width,height); matrixCopy(temp_last,dst,width,height); free(temp); free(temp_last); }
bool System::texture_isSmooth(unsigned int id) { auto texture = mTextureHandler.get(id); if(nullptr == texture) { return false; } return texture->isSmooth(); }
sfBool sfRenderTexture_isSmooth(const sfRenderTexture* renderTexture) { CSFML_CALL_RETURN(renderTexture, isSmooth(), sfFalse); }